Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/content/TextInput.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ Native `<input>` attributes are forwarded to the underlying React `input` compon
| block | Boolean | | Adds `display: block` to element |
| variant | String | | Can be either `small` or `large`. Creates a smaller or larger input than the default.
| width | String or Number | | Set the width of the input |
| maxWidth | String or Number or [Array](https://styled-system.com/guides/array-props) | | Set the maximum width of the input |
| minWidth | String or Number or [Array](https://styled-system.com/guides/array-props) | | Set the minimum width of the input |
| icon | Node (pass Octicon react component) | | Icon to be used inside of input. Positioned on the right edge. |
2 changes: 2 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ declare module '@primer/components' {
export interface TextInputProps
extends CommonProps,
StyledSystem.WidthProps,
StyledSystem.MaxWidthProps,
StyledSystem.MinWidthProps,
Omit<React.InputHTMLAttributes<HTMLInputElement>, 'color' | 'size' | 'width'> {
block?: boolean
icon?: React.ReactElement
Expand Down
6 changes: 5 additions & 1 deletion src/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import systemPropTypes from '@styled-system/prop-types'
import {omit, pick} from '@styled-system/props'
import styled, {css} from 'styled-components'
import Octicon from './StyledOcticon'
import {variant, width} from 'styled-system'
import {variant, width, minWidth, maxWidth} from 'styled-system'
import {COMMON, get} from './constants'
import theme from './theme'

Expand Down Expand Up @@ -120,13 +120,17 @@ const Wrapper = styled.span`
}
${COMMON}
${width}
${minWidth}
${maxWidth}
${sizeVariants}
`

TextInput.defaultProps = {theme}

TextInput.propTypes = {
block: PropTypes.bool,
maxWidth: systemPropTypes.layout.maxWidth,
minWidth: systemPropTypes.layout.minWidth,
variant: PropTypes.oneOf(['small', 'large']),
...COMMON.propTypes,
width: systemPropTypes.layout.width
Expand Down