An open source design system that's fully customizable and agent ready
TypeScript
fix(templates): set fixed 300px width on all TextInput examples (#1694)
Kenton Quatman71a3495480d9
diff --git a/packages/cli/templates/blocks/components/TextInput/TextInputWithIcon.doc.mjs b/packages/cli/templates/blocks/components/TextInput/TextInputIcon.doc.mjssimilarity index 94%rename from packages/cli/templates/blocks/components/TextInput/TextInputWithIcon.doc.mjsrename to packages/cli/templates/blocks/components/TextInput/TextInputIcon.doc.mjsindex 67208cad17..bfed31a354 100644--- a/packages/cli/templates/blocks/components/TextInput/TextInputWithIcon.doc.mjs+++ b/packages/cli/templates/blocks/components/TextInput/TextInputIcon.doc.mjs@@ -4,6 +4,6 @@ export const doc = {name: 'TextInput — Icon',description: 'Inputs with a leading icon that hints at the expected content. Use when the icon helps users identify the field faster, like a lock for passwords or an envelope for email.',isReady: true,- aspectRatio: 4 / 3,+ aspectRatio: 16 / 9,componentsUsed: ['TextInput', 'Layout'],};diff --git a/packages/cli/templates/blocks/components/TextInput/TextInputIcon.tsx b/packages/cli/templates/blocks/components/TextInput/TextInputIcon.tsxnew file mode 100644index 0000000000..9f678e6c86--- /dev/null+++ b/packages/cli/templates/blocks/components/TextInput/TextInputIcon.tsx@@ -0,0 +1,46 @@+'use client';++import {useState} from 'react';+import {XDSTextInput} from '@xds/core/TextInput';+import {XDSStack} from '@xds/core/Layout';+import {+ EnvelopeIcon,+ LockClosedIcon,+ UserIcon,+} from '@heroicons/react/24/outline';++export default function TextInputIcon() {+ const [name, setName] = useState('');+ const [email, setEmail] = useState('');+ const [password, setPassword] = useState('');++ return (+ <div style={{width: 300}}>+ <XDSStack direction="vertical" gap={3}>+ <XDSTextInput+ label="Full name"+ value={name}+ onChange={setName}+ placeholder="Sarah Chen"+ startIcon={UserIcon}+ />+ <XDSTextInput+ type="email"+ label="Email"+ value={email}+ onChange={setEmail}+ placeholder="[email protected]"+ startIcon={EnvelopeIcon}+ />+ <XDSTextInput+ type="password"+ label="Password"+ value={password}+ onChange={setPassword}+ placeholder="Enter your password"+ startIcon={LockClosedIcon}+ />+ </XDSStack>+ </div>+ );+}diff --git a/packages/cli/templates/blocks/components/TextInput/TextInputSearchInput.doc.mjs b/packages/cli/templates/blocks/components/TextInput/TextInputSearch.doc.mjssimilarity index 100%rename from packages/cli/templates/blocks/components/TextInput/TextInputSearchInput.doc.mjsrename to packages/cli/templates/blocks/components/TextInput/TextInputSearch.doc.mjsdiff --git a/packages/cli/templates/blocks/components/TextInput/TextInputSearch.tsx b/packages/cli/templates/blocks/components/TextInput/TextInputSearch.tsxnew file mode 100644index 0000000000..4f3644be8d--- /dev/null+++ b/packages/cli/templates/blocks/components/TextInput/TextInputSearch.tsx@@ -0,0 +1,34 @@+'use client';++import {useState} from 'react';+import {XDSTextInput} from '@xds/core/TextInput';+import {XDSStack} from '@xds/core/Layout';+import {MagnifyingGlassIcon} from '@heroicons/react/24/outline';++export default function TextInputSearch() {+ const [query, setQuery] = useState('');+ const [filter, setFilter] = useState('design systems');++ return (+ <div style={{width: 300}}>+ <XDSStack direction="vertical" gap={3}>+ <XDSTextInput+ label="Search field"+ value={query}+ onChange={setQuery}+ placeholder="Search projects…"+ startIcon={MagnifyingGlassIcon}+ hasClear+ />+ <XDSTextInput+ label="Search field with value"+ value={filter}+ onChange={setFilter}+ placeholder="Filter…"+ startIcon={MagnifyingGlassIcon}+ hasClear+ />+ </XDSStack>+ </div>+ );+}diff --git a/packages/cli/templates/blocks/components/TextInput/TextInputSearchInput.tsx b/packages/cli/templates/blocks/components/TextInput/TextInputSearchInput.tsxdeleted file mode 100644index bd6401a8f2..0000000000--- a/packages/cli/templates/blocks/components/TextInput/TextInputSearchInput.tsx+++ /dev/null@@ -1,34 +0,0 @@-'use client';--import {useState} from 'react';-import {XDSTextInput} from '@xds/core/TextInput';-import {XDSStack} from '@xds/core/Layout';-import {MagnifyingGlassIcon} from '@heroicons/react/24/outline';--export default function TextInputSearchInput() {- const [query, setQuery] = useState('');- const [filter, setFilter] = useState('design systems');-- return (- <XDSStack direction="vertical" gap={3}>- <XDSTextInput- label="Search"- isLabelHidden- value={query}- onChange={setQuery}- placeholder="Search projects…"- startIcon={MagnifyingGlassIcon}- hasClear- />- <XDSTextInput- label="Filter results"- isLabelHidden- value={filter}- onChange={setFilter}- placeholder="Filter…"- startIcon={MagnifyingGlassIcon}- hasClear- />- </XDSStack>- );-}diff --git a/packages/cli/templates/blocks/components/TextInput/TextInputShowcase.tsx b/packages/cli/templates/blocks/components/TextInput/TextInputShowcase.tsxindex 21b56c71c4..e0e53fedc5 100644--- a/packages/cli/templates/blocks/components/TextInput/TextInputShowcase.tsx+++ b/packages/cli/templates/blocks/components/TextInput/TextInputShowcase.tsx@@ -4,11 +4,13 @@ import {XDSTextInput} from '@xds/core/TextInput';export default function TextInputShowcase() {return (- <XDSTextInput- label="Name"- value=""- onChange={() => {}}- placeholder="Enter your name"- />+ <div style={{width: 300}}>+ <XDSTextInput+ label="Name"+ value=""+ onChange={() => {}}+ placeholder="Enter your name"+ />+ </div>);}diff --git a/packages/cli/templates/blocks/components/TextInput/TextInputSizes.doc.mjs b/packages/cli/templates/blocks/components/TextInput/TextInputSizes.doc.mjsindex 4f9b4d7900..833060ee9b 100644--- a/packages/cli/templates/blocks/components/TextInput/TextInputSizes.doc.mjs+++ b/packages/cli/templates/blocks/components/TextInput/TextInputSizes.doc.mjs@@ -4,6 +4,6 @@ export const doc = {name: 'TextInput — Sizes',description: 'Small, medium, and large inputs side by side. Use small in dense UIs like table filters, medium for most forms, and large for prominent single-field pages.',isReady: true,- aspectRatio: 4 / 3,+ aspectRatio: 16 / 9,componentsUsed: ['TextInput', 'Layout'],};diff --git a/packages/cli/templates/blocks/components/TextInput/TextInputSizes.tsx b/packages/cli/templates/blocks/components/TextInput/TextInputSizes.tsxindex c592d8d0b8..3f911726ae 100644--- a/packages/cli/templates/blocks/components/TextInput/TextInputSizes.tsx+++ b/packages/cli/templates/blocks/components/TextInput/TextInputSizes.tsx@@ -10,28 +10,30 @@ export default function TextInputSizes() {const [lg, setLg] = useState('');return (- <XDSStack direction="vertical" gap={3}>- <XDSTextInput- label="Small"- value={sm}- onChange={setSm}- placeholder="Enter a value"- size="sm"- />- <XDSTextInput- label="Medium"- value={md}- onChange={setMd}- placeholder="Enter a value"- size="md"- />- <XDSTextInput- label="Large"- value={lg}- onChange={setLg}- placeholder="Enter a value"- size="lg"- />- </XDSStack>+ <div style={{width: 300}}>+ <XDSStack direction="vertical" gap={3}>+ <XDSTextInput+ label="Small"+ value={sm}+ onChange={setSm}+ placeholder="Enter a value"+ size="sm"+ />+ <XDSTextInput+ label="Medium"+ value={md}+ onChange={setMd}+ placeholder="Enter a value"+ size="md"+ />+ <XDSTextInput+ label="Large"+ value={lg}+ onChange={setLg}+ placeholder="Enter a value"+ size="lg"+ />+ </XDSStack>+ </div>);}diff --git a/packages/cli/templates/blocks/components/TextInput/TextInputStates.doc.mjs b/packages/cli/templates/blocks/components/TextInput/TextInputStates.doc.mjsindex e670f9e55d..443562bcbd 100644--- a/packages/cli/templates/blocks/components/TextInput/TextInputStates.doc.mjs+++ b/packages/cli/templates/blocks/components/TextInput/TextInputStates.doc.mjs@@ -2,8 +2,8 @@export const doc = {type: 'block',name: 'TextInput — States',- description: 'Text, password, and email inputs in default, disabled, and loading states. Shows the three input types side by side with realistic data.',+ description: 'Error, warning, and success validation states with status messages. Use to show users what went wrong and how to fix it.',isReady: true,- aspectRatio: 4 / 3,+ aspectRatio: 9 / 16,componentsUsed: ['TextInput', 'Layout'],};diff --git a/packages/cli/templates/blocks/components/TextInput/TextInputStates.tsx b/packages/cli/templates/blocks/components/TextInput/TextInputStates.tsxindex 604b4bbf65..3e05cecaca 100644--- a/packages/cli/templates/blocks/components/TextInput/TextInputStates.tsx+++ b/packages/cli/templates/blocks/components/TextInput/TextInputStates.tsx@@ -5,45 +5,62 @@ import {XDSTextInput} from '@xds/core/TextInput';import {XDSStack} from '@xds/core/Layout';export default function TextInputStates() {- const [text, setText] = useState('Sarah Chen');- const [password, setPassword] = useState('hunter42');- const [email, setEmail] = useState('[email protected]');+ const [error, setError] = useState('sarah@');+ const [warning, setWarning] = useState('sarah_chen');+ const [success, setSuccess] = useState('https://sarahchen.dev');+ const [errorOnly, setErrorOnly] = useState('test');return (- <XDSStack direction="vertical" gap={3}>- <XDSTextInput- label="Default field"- value={text}- onChange={setText}- placeholder="Enter a value"- />- <XDSTextInput- type="password"- label="Password field"- value={password}- onChange={setPassword}- placeholder="Enter a value"- />- <XDSTextInput- type="email"- label="Email field"- value={email}- onChange={setEmail}- placeholder="Enter a value"- />- <XDSTextInput- label="Disabled field"- value=""- onChange={() => {}}- placeholder="Enter a value"- isDisabled- />- <XDSTextInput- label="Loading field"- value="sarahc"- onChange={() => {}}- isLoading- />- </XDSStack>+ <div style={{width: 300}}>+ <XDSStack direction="vertical" gap={3}>+ <XDSTextInput+ label="Error message"+ value={error}+ onChange={setError}+ placeholder="Enter a value"+ status={{+ type: 'error',+ message: 'Please enter a valid email address.',+ }}+ />+ <XDSTextInput+ label="Warning message"+ value={warning}+ onChange={setWarning}+ placeholder="Enter a value"+ status={{+ type: 'warning',+ message: 'This username is already taken — try adding a number.',+ }}+ />+ <XDSTextInput+ label="Success message"+ value={success}+ onChange={setSuccess}+ placeholder="Enter a value"+ status={{type: 'success', message: 'URL is valid and reachable.'}}+ />+ <XDSTextInput+ label="Status without message"+ value={errorOnly}+ onChange={setErrorOnly}+ placeholder="Enter a value"+ status={{type: 'error'}}+ />+ <XDSTextInput+ label="Disabled field"+ value=""+ onChange={() => {}}+ placeholder="Enter a value"+ isDisabled+ />+ <XDSTextInput+ label="Loading field"+ value="sarahc"+ onChange={() => {}}+ isLoading+ />+ </XDSStack>+ </div>);}diff --git a/packages/cli/templates/blocks/components/TextInput/TextInputTypes.doc.mjs b/packages/cli/templates/blocks/components/TextInput/TextInputTypes.doc.mjsnew file mode 100644index 0000000000..b95f9f1f6b--- /dev/null+++ b/packages/cli/templates/blocks/components/TextInput/TextInputTypes.doc.mjs@@ -0,0 +1,9 @@+/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */+export const doc = {+ type: 'block',+ name: 'TextInput — Types',+ description: 'Text, password, and email types plus field-level features: tooltip, required, optional, description, disabled, and loading.',+ isReady: true,+ aspectRatio: 1 / 1,+ componentsUsed: ['TextInput', 'Layout'],+};diff --git a/packages/cli/templates/blocks/components/TextInput/TextInputTypes.tsx b/packages/cli/templates/blocks/components/TextInput/TextInputTypes.tsxnew file mode 100644index 0000000000..7955421c7c--- /dev/null+++ b/packages/cli/templates/blocks/components/TextInput/TextInputTypes.tsx@@ -0,0 +1,63 @@+'use client';++import {useState} from 'react';+import {XDSTextInput} from '@xds/core/TextInput';+import {XDSStack} from '@xds/core/Layout';++export default function TextInputTypes() {+ const [password, setPassword] = useState('hunter42');+ const [email, setEmail] = useState('[email protected]');+ const [tooltip, setTooltip] = useState('');+ const [required, setRequired] = useState('');+ const [optional, setOptional] = useState('');+ const [described, setDescribed] = useState('');++ return (+ <div style={{width: 300}}>+ <XDSStack direction="vertical" gap={3}>+ <XDSTextInput+ label="Default field"+ value={described}+ onChange={setDescribed}+ placeholder="Enter your email"+ description="Descriptions can be used to provide additional information about a field."+ />+ <XDSTextInput+ type="password"+ label="Password field"+ value={password}+ onChange={setPassword}+ placeholder="Enter a value"+ />+ <XDSTextInput+ type="email"+ label="Email field"+ value={email}+ onChange={setEmail}+ placeholder="Enter a value"+ />+ <XDSTextInput+ label="Field tooltip"+ value={tooltip}+ onChange={setTooltip}+ placeholder="Enter your API key"+ labelTooltip="Your unique API key for authentication. Keep this secret!"+ />+ <XDSTextInput+ label="Required field"+ value={required}+ onChange={setRequired}+ placeholder="Enter your username"+ isRequired+ />+ <XDSTextInput+ label="Optional field"+ value={optional}+ onChange={setOptional}+ placeholder="Enter your nickname"+ isOptional+ />+ </XDSStack>+ </div>+ );+}diff --git a/packages/cli/templates/blocks/components/TextInput/TextInputWithIcon.tsx b/packages/cli/templates/blocks/components/TextInput/TextInputWithIcon.tsxdeleted file mode 100644index 4b51fcbd2a..0000000000--- a/packages/cli/templates/blocks/components/TextInput/TextInputWithIcon.tsx+++ /dev/null@@ -1,53 +0,0 @@-'use client';--import {useState} from 'react';-import {XDSTextInput} from '@xds/core/TextInput';-import {XDSStack} from '@xds/core/Layout';-import {- EnvelopeIcon,- LockClosedIcon,- UserIcon,- GlobeAltIcon,-} from '@heroicons/react/24/outline';--export default function TextInputWithIcon() {- const [name, setName] = useState('');- const [email, setEmail] = useState('');- const [password, setPassword] = useState('');- const [website, setWebsite] = useState('');-- return (- <XDSStack direction="vertical" gap={3}>- <XDSTextInput- label="Full name"- value={name}- onChange={setName}- placeholder="Sarah Chen"- startIcon={UserIcon}- />- <XDSTextInput- type="email"- label="Email"- value={email}- onChange={setEmail}- placeholder="[email protected]"- startIcon={EnvelopeIcon}- />- <XDSTextInput- type="password"- label="Password"- value={password}- onChange={setPassword}- placeholder="Enter your password"- startIcon={LockClosedIcon}- />- <XDSTextInput- label="Website"- value={website}- onChange={setWebsite}- placeholder="https://example.com"- startIcon={GlobeAltIcon}- />- </XDSStack>- );-}diff --git a/packages/cli/templates/blocks/components/TextInput/TextInputWithValidation.doc.mjs b/packages/cli/templates/blocks/components/TextInput/TextInputWithValidation.doc.mjsdeleted file mode 100644index 677ffa9ea2..0000000000--- a/packages/cli/templates/blocks/components/TextInput/TextInputWithValidation.doc.mjs+++ /dev/null@@ -1,9 +0,0 @@-/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */-export const doc = {- type: 'block',- name: 'TextInput — Validation',- description: 'Error, warning, and success validation states with status messages. Use to show users what went wrong and how to fix it.',- isReady: true,- aspectRatio: 4 / 3,- componentsUsed: ['TextInput', 'Layout'],-};diff --git a/packages/cli/templates/blocks/components/TextInput/TextInputWithValidation.tsx b/packages/cli/templates/blocks/components/TextInput/TextInputWithValidation.tsxdeleted file mode 100644index c3d443ff5a..0000000000--- a/packages/cli/templates/blocks/components/TextInput/TextInputWithValidation.tsx+++ /dev/null@@ -1,37 +0,0 @@-'use client';--import {useState} from 'react';-import {XDSTextInput} from '@xds/core/TextInput';-import {XDSStack} from '@xds/core/Layout';--export default function TextInputWithValidation() {- const [error, setError] = useState('sarah@');- const [warning, setWarning] = useState('sarah_chen');- const [success, setSuccess] = useState('https://sarahchen.dev');-- return (- <XDSStack direction="vertical" gap={3}>- <XDSTextInput- label="Error message"- value={error}- onChange={setError}- placeholder="Enter a value"- status={{type: 'error', message: 'Please enter a valid email address.'}}- />- <XDSTextInput- label="Warning message"- value={warning}- onChange={setWarning}- placeholder="Enter a value"- status={{type: 'warning', message: 'This username is already taken — try adding a number.'}}- />- <XDSTextInput- label="Success message"- value={success}- onChange={setSuccess}- placeholder="Enter a value"- status={{type: 'success', message: 'URL is valid and reachable.'}}- />- </XDSStack>- );-}