Components
Textfield
Textfield allows users to enter free text or numbers.
React
Press Enter to start editing
const Preview = () => { return <Textfield label='Label' />; }; render(<Preview />)
Usage
Examples
With rows
React
Press Enter to start editing
const WithRows = () => { return <Textfield label='Label' multiline rows={4} />; }; render(<WithRows />)
With prefix and suffix
React
Press Enter to start editing
const WithAffixEn = () => { return ( <Textfield prefix='GBP' suffix='per month' label='How much does it cost per month?' /> ); }; render(<WithAffixEn />)
With counter
React
Press Enter to start editing
const WithCounterEn = () => { return ( <Textfield counter={10} label='How many pounds does it cost per month?' /> ); }; render(<WithCounterEn />)
HTML
This is a composite component, which uses Field, Input or Textarea and Label under the hood.
Since this component is built from multiple components, we recommend reading the documentation for the underlying components to get a full overview of the HTML structure.
CSS variables and data attributes
Textfield is a composite component, with Field, Input or Textarea and Label.
Here we only show ds-input's variables and data attributes.
| Name | Value |
|---|---|
| --dsc-input-padding | var(--ds-size-2) var(--ds-size-3) |
| --dsc-input-size--toggle | var(--ds-size-6) |
| --dsc-input-size | var(--ds-size-12) |
| --dsc-input-background--readonly | var(--ds-color-neutral-surface-tinted) |
| --dsc-input-background | var(--ds-color-neutral-surface-default) |
| --dsc-input-border-color--readonly | var(--ds-color-neutral-border-subtle) |
| --dsc-input-border-color | var(--ds-color-neutral-border-default) |
| --dsc-input-border-style | solid |
| --dsc-input-border-width--toggle | max(var(--ds-border-width-default),calc(var(--ds-size-1)/2)) |
| --dsc-input-border-width | var(--ds-border-width-default) |
| --dsc-input-outline-color--hover | var(--ds-color-neutral-border-default) |
| --dsc-input-outline-color--toggle--hover | var(--dsc-input-accent-color) |
| --dsc-input-outline-width--hover | var(--ds-border-width-default) |
| --dsc-input-outline-style--hover | solid |
| --dsc-input-color--readonly | var(--ds-color-neutral-text-default) |
| --dsc-input-color | var(--ds-color-neutral-text-default) |
| --dsc-input-stroke-color | var(--ds-color-base-contrast-default) |
| --dsc-input-stroke-color--invalid | var(--ds-color-danger-base-contrast-default) |
| --dsc-input-stroke-width | 0.05em |
| --dsc-input-accent-color | var(--ds-color-base-default) |
| --dsc-input-accent-color--invalid | var(--ds-color-danger-text-subtle) |
| Name | Value |
|---|---|
| data-width | auto |