@bykhd/lab-ds 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,77 @@
1
+ # Field
2
+
3
+ Lays out one form control with its label, help text, and error message, and groups related fields.
4
+
5
+ ## When to use
6
+
7
+ - Around every form control (`Input`, `Textarea`, `Checkbox`, `InputGroup`, `InputOTP`) so the label, help text, and error line up the same way everywhere.
8
+ - To group related controls (a set of checkboxes, an address) under one heading with `FieldSet` and `FieldLegend`.
9
+
10
+ ## When not to use
11
+
12
+ - For an error about the whole form, not one field. Use `Alert` above the form.
13
+ - For layout that has no form control in it. Use layout spacing.
14
+
15
+ ## Rules
16
+
17
+ - Every control needs a visible label. A placeholder is not a label: it disappears as soon as the user types.
18
+ - Labels are short, in sentence case, with no colon.
19
+ - Help text (`FieldDescription`) is one short sentence. Show it before the user makes a mistake, not only after.
20
+ - Error messages (`FieldError`) say what to do: "Enter an email address like name@example.com", not "Invalid input".
21
+ - When a field has an error, mark its control with `aria-invalid` so it turns red too, and link the message to the control.
22
+ - TODO: decide how required and optional fields are marked.
23
+
24
+ ## Parts
25
+
26
+ | Part | What it is |
27
+ | --- | --- |
28
+ | `Field` | One control with its label and text. |
29
+ | `FieldLabel` | The label for the control. Wrapping a whole `Field` in it turns the row into a selectable card that highlights when checked. |
30
+ | `FieldTitle` | A label-styled title when the control has its own label elsewhere. |
31
+ | `FieldContent` | Stacks a label and description next to a checkbox in a horizontal Field. |
32
+ | `FieldDescription` | Help text in a muted color. Links inside are underlined. |
33
+ | `FieldError` | The error message, in red. Shows nothing when it has no message. Screen readers announce it when it appears. |
34
+ | `FieldGroup` | Stacks several Fields with even spacing. |
35
+ | `FieldSet` | Groups related Fields. |
36
+ | `FieldLegend` | The heading of a `FieldSet`. |
37
+ | `FieldSeparator` | A divider line between groups, optionally with text in the middle ("Or continue with"). |
38
+
39
+ ## Props and variants
40
+
41
+ | Part | Prop | Values | Default | What it does |
42
+ | --- | --- | --- | --- | --- |
43
+ | `Field` | `orientation` | `vertical`, `horizontal`, `responsive` | `vertical` | `vertical`: label above the control. `horizontal`: label beside the control (use for checkboxes). `responsive`: vertical in narrow containers, horizontal in wider ones. |
44
+ | `FieldLegend` | `variant` | `legend`, `label` | `legend` | `legend` is base size; `label` is smaller, to match a field label. |
45
+ | `FieldError` | `errors` | list of messages | not set | Shows one message as text, several as a bullet list; repeats are removed. |
46
+
47
+ ## Tokens used
48
+
49
+ | Token | Where |
50
+ | --- | --- |
51
+ | `--color-on-base-content-high` | Legend text |
52
+ | `--color-on-base-content-medium` | Help text, separator text |
53
+ | `--color-primary-content-default` | Link hover in help text |
54
+ | `--color-danger-content-default` | Error text, and the whole Field when invalid |
55
+ | `--color-primary-border-default`, `--color-primary-foreground-subtle` | Selectable card when checked |
56
+ | `--color-base-foreground-action-hover` | Selectable card on hover |
57
+ | `--color-primary-border-strong` | Selectable card focus ring |
58
+ | `--color-base-foreground-ground`, `--color-base-foreground-card` | Background behind separator text (page or card) |
59
+ | `--radius-lg` | Selectable card corners |
60
+
61
+ Label text uses the `Label` component's styles. All color tokens have dark-mode values and switch automatically.
62
+
63
+ ## Example
64
+
65
+ From the `WithError` story:
66
+
67
+ ```tsx
68
+ import { Field, FieldError, FieldLabel, Input } from "@bykhd/lab-ds"
69
+
70
+ <Field data-invalid="true">
71
+ <FieldLabel htmlFor="email-err">Email</FieldLabel>
72
+ <Input id="email-err" type="email" defaultValue="you@" aria-invalid aria-describedby="email-err-msg" />
73
+ <FieldError id="email-err-msg">Enter an email address like name@example.com.</FieldError>
74
+ </Field>
75
+ ```
76
+
77
+ The stories also show `Default` (label, input, help text) and `FieldSetWithLegend` (a group of checkboxes).
@@ -0,0 +1,62 @@
1
+ # Input
2
+
3
+ A single-line text box for short answers such as a name, an email address, or a number.
4
+
5
+ ## When to use
6
+
7
+ - For short, single-line answers.
8
+ - With a matching `type` (`email`, `tel`, `number`, `password`, `search`, `file`) so phones show the right keyboard and browsers can autofill.
9
+
10
+ ## When not to use
11
+
12
+ - For answers longer than one line. Use `Textarea`.
13
+ - When the input needs an icon, prefix, suffix, or button inside it. Use `InputGroup`.
14
+ - For one-time codes. Use `InputOTP`.
15
+ - For picking from a fixed list or a yes/no choice. Use `Checkbox`. TODO: lab-ds has no select, radio, or combobox yet.
16
+
17
+ ## Rules
18
+
19
+ - Always give it a visible label (use `Field`, or `Label`). A placeholder is not a label.
20
+ - Use the placeholder only for an example of the format, if at all.
21
+ - Set `autocomplete` for personal details (name, email, address) so browsers can fill them in.
22
+ - Show errors with `aria-invalid` and a `FieldError` message.
23
+
24
+ ## Props and variants
25
+
26
+ There are no visual variants and one size (32px tall). It fills the width of its container.
27
+
28
+ It accepts every native input prop. The ones that change how it looks:
29
+
30
+ | Prop | Values | What it does |
31
+ | --- | --- | --- |
32
+ | `disabled` | `true`, `false` | Greyed out and can't be focused or changed. |
33
+ | `aria-invalid` | `true`, `false` | Red border. |
34
+ | `type="file"` | | Shows a file picker button inside the box. |
35
+
36
+ ## Tokens used
37
+
38
+ | Token | Where |
39
+ | --- | --- |
40
+ | `--color-base-foreground-action` / `-hover` | Background, and on hover |
41
+ | `--color-on-base-border-default` | Border |
42
+ | `--color-on-base-content-high` | Text |
43
+ | `--color-on-base-content-low` | Placeholder |
44
+ | `--color-primary-border-strong` | Focus border and ring |
45
+ | `--color-base-foreground-disable`, `--color-on-base-border-disable`, `--color-on-base-content-low`, `--color-on-base-content-disable` | Disabled background, border, text, placeholder |
46
+ | `--color-danger-border-strong` / `--color-danger-border-default` | Invalid border, and on hover |
47
+ | `--radius-comp-input` (0.5rem) | Corners |
48
+
49
+ All color tokens have dark-mode values and switch automatically.
50
+
51
+ ## Example
52
+
53
+ From the `Default` story:
54
+
55
+ ```tsx
56
+ import { Input, Label } from "@bykhd/lab-ds"
57
+
58
+ <Label htmlFor="project">Project name</Label>
59
+ <Input id="project" placeholder="Website redesign" />
60
+ ```
61
+
62
+ The stories also show `Disabled`, `Invalid`, and `File`.
@@ -0,0 +1,72 @@
1
+ # InputGroup
2
+
3
+ A text box with icons, fixed text, or buttons attached inside its border.
4
+
5
+ ## When to use
6
+
7
+ - To add an icon that explains the field, such as a search icon.
8
+ - To show fixed text the user doesn't type, such as `https://` or a currency or unit.
9
+ - To attach a small action to the field, such as "Copy" or "Clear".
10
+ - For a comment box with actions under the text (`InputGroupTextarea` with a bottom addon).
11
+
12
+ ## When not to use
13
+
14
+ - For a plain text box. Use `Input` or `Textarea`.
15
+ - For the form's main submit action. Put a `Button` after the field instead.
16
+ - For several actions. Keep it to one or two small buttons.
17
+ - As a replacement for a label. The field still needs a visible label or, at minimum, an `aria-label`.
18
+
19
+ ## Parts
20
+
21
+ | Part | What it is |
22
+ | --- | --- |
23
+ | `InputGroup` | The bordered box that holds everything. |
24
+ | `InputGroupInput` | The single-line text box inside. |
25
+ | `InputGroupTextarea` | A multi-line text box inside, instead of the input. |
26
+ | `InputGroupAddon` | A slot for an icon, text, or button. Clicking an empty part of it focuses the input. |
27
+ | `InputGroupText` | Muted text inside an addon. |
28
+ | `InputGroupButton` | A small `Button` sized to fit inside the box. |
29
+
30
+ ## Props and variants
31
+
32
+ | Part | Prop | Values | Default | What it does |
33
+ | --- | --- | --- | --- | --- |
34
+ | `InputGroupAddon` | `align` | `inline-start`, `inline-end`, `block-start`, `block-end` | `inline-start` | Before the text, after the text, above it, or below it. |
35
+ | `InputGroupButton` | `size` | `xs`, `sm`, `icon-xs`, `icon-sm` | `xs` | Use `icon-*` sizes for icon-only buttons, with an `aria-label`. |
36
+ | `InputGroupButton` | `variant` | Same as `Button` | `ghost` | Keep `ghost` in a row; `default` is fine for a single "Post" or "Send" action below a textarea. |
37
+
38
+ The box is 32px tall, or grows when it holds a textarea or a top/bottom addon. Disabled and invalid states come from the input inside (`disabled`, `aria-invalid`).
39
+
40
+ ## Tokens used
41
+
42
+ | Token | Where |
43
+ | --- | --- |
44
+ | `--color-base-foreground-action` | Background |
45
+ | `--color-on-base-border-default` | Border |
46
+ | `--color-on-base-content-medium` | Addon icons and text |
47
+ | `--color-primary-border-strong` | Focus border and ring |
48
+ | `--color-base-foreground-disable`, `--color-on-base-border-disable` | Disabled background and border |
49
+ | `--color-danger-border-strong` | Invalid border and ring |
50
+ | `--radius-comp-input` (0.5rem) | Corners |
51
+
52
+ Text inside uses the `Input` / `Textarea` tokens and buttons use the `Button` tokens. All color tokens have dark-mode values and switch automatically.
53
+
54
+ ## Example
55
+
56
+ From the `WithButton` story:
57
+
58
+ ```tsx
59
+ import { IconCopy } from "@tabler/icons-react"
60
+ import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from "@bykhd/lab-ds"
61
+
62
+ <InputGroup>
63
+ <InputGroupInput readOnly defaultValue="https://example.com/invite/8f2k" aria-label="Invite link" />
64
+ <InputGroupAddon align="inline-end">
65
+ <InputGroupButton size="icon-xs" aria-label="Copy link">
66
+ <IconCopy />
67
+ </InputGroupButton>
68
+ </InputGroupAddon>
69
+ </InputGroup>
70
+ ```
71
+
72
+ The stories also show `Default` (search icon), `WithText` (prefix and suffix), and `WithTextarea`.
@@ -0,0 +1,84 @@
1
+ # InputOTP
2
+
3
+ A row of boxes for entering a short one-time code, such as a 6-digit verification code.
4
+
5
+ ## When to use
6
+
7
+ - For a verification or sign-in code sent by SMS, email, or an authenticator app.
8
+ - For a short PIN of fixed length.
9
+
10
+ ## When not to use
11
+
12
+ - For passwords or any value of unknown length. Use `Input` with `type="password"`.
13
+ - For long codes like license keys or recovery codes. Use `Input`.
14
+
15
+ ## Rules
16
+
17
+ - Show one box per character. The number of boxes must match the code length.
18
+ - Give it a label that says where the code came from ("Enter the code we sent to 08x-xxx-1234").
19
+ - Keep the browser's one-time-code autofill working. Don't turn autocomplete off.
20
+ - People can paste the whole code; it fills every box. It's one field, so Tab moves past it in one step.
21
+ - Tell people how to get a new code if theirs expired.
22
+ - Group 6-digit codes as 3 + 3 with a separator; keep 4-digit codes in one group.
23
+
24
+ ## Parts
25
+
26
+ | Part | What it is |
27
+ | --- | --- |
28
+ | `InputOTP` | The field. Holds the groups. |
29
+ | `InputOTPGroup` | A set of joined boxes. |
30
+ | `InputOTPSlot` | One box, showing one character. The active box gets a focus ring and a blinking caret. |
31
+ | `InputOTPSeparator` | A dash between groups. |
32
+
33
+ ## Props and variants
34
+
35
+ There are no visual variants and one size (32px boxes).
36
+
37
+ | Prop | Values | Default | What it does |
38
+ | --- | --- | --- | --- |
39
+ | `maxLength` | number | required | Code length. Must match the number of slots. |
40
+ | `pattern` | pattern | any character | Which characters are allowed, e.g. digits only. |
41
+ | `value` / `onChange` | string / function | not set | Control the code yourself. |
42
+ | `onComplete` | function | not set | Runs when every box is filled, e.g. to submit. |
43
+ | `disabled` | `true`, `false` | `false` | Shown at half opacity and can't be changed. |
44
+ | `index` (on `InputOTPSlot`) | number | required | Which character this box shows, from 0. |
45
+
46
+ `aria-invalid` on a slot shows a red border. TODO: confirm how an invalid code should be shown (slot borders vs a `FieldError` below).
47
+
48
+ ## Tokens used
49
+
50
+ | Token | Where |
51
+ | --- | --- |
52
+ | `--color-base-foreground-action` | Box background |
53
+ | `--color-on-base-border-default` | Box borders |
54
+ | `--color-on-base-content-high` | Characters and caret |
55
+ | `--color-primary-border-strong` | Active box border and ring |
56
+ | `--color-danger-border-strong` | Invalid border and ring |
57
+ | `--radius-comp-input` (0.5rem) | Outer corners of each group |
58
+
59
+ All color tokens have dark-mode values and switch automatically.
60
+
61
+ ## Example
62
+
63
+ From the `Default` story:
64
+
65
+ ```tsx
66
+ import { REGEXP_ONLY_DIGITS } from "input-otp"
67
+ import { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot } from "@bykhd/lab-ds"
68
+
69
+ <InputOTP maxLength={6} pattern={REGEXP_ONLY_DIGITS} aria-label="Verification code">
70
+ <InputOTPGroup>
71
+ <InputOTPSlot index={0} />
72
+ <InputOTPSlot index={1} />
73
+ <InputOTPSlot index={2} />
74
+ </InputOTPGroup>
75
+ <InputOTPSeparator />
76
+ <InputOTPGroup>
77
+ <InputOTPSlot index={3} />
78
+ <InputOTPSlot index={4} />
79
+ <InputOTPSlot index={5} />
80
+ </InputOTPGroup>
81
+ </InputOTP>
82
+ ```
83
+
84
+ The stories also show `FourDigits` and `Disabled`.
@@ -0,0 +1,47 @@
1
+ # Label
2
+
3
+ The visible name of a form control.
4
+
5
+ ## When to use
6
+
7
+ - For every form control that has no other visible name: `Input`, `Textarea`, `Checkbox`, `InputOTP`.
8
+ - Linked to its control (`htmlFor` matching the control's `id`), so clicking the label focuses or toggles the control and screen readers read it out.
9
+
10
+ ## When not to use
11
+
12
+ - Inside a `Field`. Use `FieldLabel`, which is a Label with Field spacing.
13
+ - For a heading over a group of controls. Use `FieldLegend` inside a `FieldSet`.
14
+ - For help text or instructions. Use `FieldDescription`.
15
+
16
+ ## Rules
17
+
18
+ - Short, in sentence case, no colon: "Project name", not "Project Name:".
19
+ - Put it above text inputs, and to the right of checkboxes.
20
+ - Never replace it with a placeholder.
21
+
22
+ ## Props and variants
23
+
24
+ There are no variants and one size (small, medium-weight text).
25
+
26
+ It accepts every native label prop; `htmlFor` is the important one.
27
+
28
+ It dims to half opacity when its control is disabled, as long as the label comes after the control or sits inside a disabled `Field`.
29
+
30
+ TODO: when the label comes before a disabled control (the usual order for inputs), it does not dim. Confirm whether that's intended.
31
+
32
+ ## Tokens used
33
+
34
+ Label sets no color tokens of its own; it uses the surrounding text color.
35
+
36
+ ## Example
37
+
38
+ From the `Default` story:
39
+
40
+ ```tsx
41
+ import { Input, Label } from "@bykhd/lab-ds"
42
+
43
+ <Label htmlFor="name">Project name</Label>
44
+ <Input id="name" />
45
+ ```
46
+
47
+ The stories also show `Disabled`.
@@ -0,0 +1,61 @@
1
+ # ProductCard
2
+
3
+ Shows one product in a shop listing: photo, brand, name, and price.
4
+
5
+ ## When to use
6
+
7
+ - In a grid or row of products that people browse and compare.
8
+ - When the product has a photo, a brand, a name, and a single price.
9
+
10
+ ## When not to use
11
+
12
+ - For anything that isn't a product for sale. Use `Card`.
13
+ - For a product detail page. ProductCard is a summary.
14
+ - When you need extra content (ratings, sale price, "Add to cart"). ProductCard takes no other content. TODO: confirm whether these are planned.
15
+ - TODO: the card isn't a link and has no hover state. Confirm how a ProductCard should open the product page.
16
+
17
+ ## Content
18
+
19
+ - **Photo:** square, cropped to fill. Write `imageAlt` to describe the product ("Orange ceramic mug, front view"); if you leave it out, the product name is used.
20
+ - **Brand:** small, muted text above the name.
21
+ - **Name:** cut off after two lines. Put the important words first.
22
+ - **Price:** a number in Thai baht. It's formatted for you (e.g. ฿390.00). TODO: currency and locale are fixed to THB / Thai; confirm whether other currencies are needed.
23
+
24
+ ## Props and variants
25
+
26
+ | Prop | Values | Default | What it does |
27
+ | --- | --- | --- | --- |
28
+ | `image` | URL | required | Product photo. |
29
+ | `imageAlt` | text | the product name | Describes the photo for screen readers. |
30
+ | `productName` | text | required | Product name. |
31
+ | `brandName` | text | required | Brand name. |
32
+ | `price` | number | required | Price in THB. |
33
+ | `size` | `default`, `sm` | `default` | Same as `Card`: `sm` uses tighter spacing. |
34
+
35
+ ## Tokens used
36
+
37
+ | Token | Where |
38
+ | --- | --- |
39
+ | `--color-base-foreground-inset` | Photo area while the image loads |
40
+ | `--color-on-base-content-medium` | Brand |
41
+ | `--color-on-base-content-high` | Price |
42
+
43
+ Background, border, corners, and name styling come from `Card`. All color tokens have dark-mode values and switch automatically.
44
+
45
+ ## Example
46
+
47
+ From the `Default` story (the story uses an inline placeholder image instead of a URL):
48
+
49
+ ```tsx
50
+ import { ProductCard } from "@bykhd/lab-ds"
51
+
52
+ <ProductCard
53
+ image="/images/mug.jpg"
54
+ imageAlt="Orange ceramic mug, front view"
55
+ productName="Stoneware mug, 350 ml"
56
+ brandName="Daidai Home"
57
+ price={390}
58
+ />
59
+ ```
60
+
61
+ The stories also show `LongName` and `Small`.
@@ -0,0 +1,51 @@
1
+ # Separator
2
+
3
+ A thin line that divides content into groups.
4
+
5
+ ## When to use
6
+
7
+ - To split sections of a panel, menu, or card when spacing alone doesn't make the grouping clear.
8
+ - Vertically, between inline items such as links in a footer.
9
+
10
+ ## When not to use
11
+
12
+ - When spacing already separates the groups. Extra lines add visual noise.
13
+ - To separate form groups with a label in the middle ("Or continue with"). Use `FieldSeparator`.
14
+ - As a page or card border. Use `Card`.
15
+ - As a resizable splitter between panes. Separator can't be dragged.
16
+
17
+ ## Props and variants
18
+
19
+ | Prop | Values | Default | What it does |
20
+ | --- | --- | --- | --- |
21
+ | `orientation` | `horizontal`, `vertical` | `horizontal` | `horizontal` spans the full width. `vertical` takes the full height of its parent, so the parent must have a height. |
22
+
23
+ The line is 1px. There are no other variants.
24
+
25
+ Screen readers announce it as a separator. TODO: confirm whether purely decorative lines should be hidden from screen readers.
26
+
27
+ ## Tokens used
28
+
29
+ | Token | Where |
30
+ | --- | --- |
31
+ | `--color-on-base-border-default` | Line color |
32
+
33
+ The token has a dark-mode value and switches automatically.
34
+
35
+ ## Example
36
+
37
+ From the `Vertical` story:
38
+
39
+ ```tsx
40
+ import { Separator } from "@bykhd/lab-ds"
41
+
42
+ <div style={{ display: "flex", alignItems: "center", gap: 12, height: 20 }}>
43
+ <span>Docs</span>
44
+ <Separator orientation="vertical" />
45
+ <span>Blog</span>
46
+ <Separator orientation="vertical" />
47
+ <span>Support</span>
48
+ </div>
49
+ ```
50
+
51
+ The stories also show `Default` (horizontal).
@@ -0,0 +1,112 @@
1
+ # Tabs
2
+
3
+ Splits related content into a few views on the same page and shows one view at a time.
4
+
5
+ ## When to use
6
+
7
+ - To group related content into 2–5 sections that people look at one at a time, such as Overview, Activity, and Settings for one project.
8
+ - When people can stay where they are and don't need every section at once.
9
+ - When the sections are about the same thing and the first section is the one most people need.
10
+
11
+ ## When not to use
12
+
13
+ - To go to another page. Use links (navigation), even if they look like tabs.
14
+ - For steps that must be done in order. TODO: lab-ds has no stepper or progress indicator yet.
15
+ - When people need to compare content across sections. Put it on one page instead.
16
+ - When people may need several sections open at once. TODO: lab-ds has no accordion yet.
17
+ - To switch between formats or filters of the same content (e.g. List / Grid). TODO: lab-ds has no segmented control or toggle group yet.
18
+ - When the page reads fine without them. Tabs hide content, and not everyone notices them.
19
+ - To hide a form field that's required or might show an error. People won't see it.
20
+ - Inside another set of Tabs.
21
+
22
+ ## Rules
23
+
24
+ - **Labels:** one or two words, sentence case, saying clearly what's in the tab. Labels don't wrap, so keep them short.
25
+ - **Order:** most needed first. Keep the order the same every time; don't reorder tabs based on use.
26
+ - **Count:** at least 2. Keep to about 4 so they fit on one row; if they don't fit, there are probably too many.
27
+ - **Always set which tab starts selected** (`defaultValue` or `value`), matching a tab that exists. Otherwise no tab is selected.
28
+ - **Disabled tabs:** prefer removing a tab that has nothing to show. If a tab is unavailable for a reason (e.g. permissions), disable it and explain why nearby. Design systems disagree here.
29
+ - **Icons:** optional, before the label. Don't use icon-only tabs.
30
+
31
+ ## Parts
32
+
33
+ | Part | What it is |
34
+ | --- | --- |
35
+ | `Tabs` | Holds the selected tab and lays out the list and panels. |
36
+ | `TabsList` | The row (or column) of tabs. |
37
+ | `TabsTrigger` | One tab. Medium-weight small text. The selected tab is darker. |
38
+ | `TabsContent` | The panel shown for one tab. Only the selected panel is shown. |
39
+
40
+ ## Props and variants
41
+
42
+ | Part | Prop | Values | Default | What it does |
43
+ | --- | --- | --- | --- | --- |
44
+ | `TabsList` | `variant` | `default`, `line` | `default` | `default`: tabs sit in a tinted, rounded track and the selected tab is a raised white pill. `line`: no track; the selected tab gets an underline (or a side line when vertical). |
45
+ | `Tabs` | `orientation` | `horizontal`, `vertical` | `horizontal` | `horizontal`: tabs in a row above the panel. `vertical`: tabs stacked to the left of the panel. |
46
+ | `Tabs` | `defaultValue` | the `value` of a tab | `0` | Which tab is selected first. Always set it. |
47
+ | `Tabs` | `value` / `onValueChange` | tab value / function | not set | Control the selected tab yourself, e.g. to keep it in the URL. |
48
+ | `TabsTrigger`, `TabsContent` | `value` | any | required | Links a tab to its panel. Use the same value on both. |
49
+ | `TabsTrigger` | `disabled` | `true`, `false` | `false` | Shown at half opacity; can't be selected. |
50
+ | `TabsList` | `activateOnFocus` | `true`, `false` | `false` | `false`: arrow keys move focus, Enter or Space selects. `true`: moving focus selects the tab. Use `true` only when panels show instantly. |
51
+ | `TabsList` | `loopFocus` | `true`, `false` | `true` | Arrow keys wrap from the last tab to the first. |
52
+ | `TabsContent` | `keepMounted` | `true`, `false` | `false` | Keeps hidden panels in the page, e.g. to keep a half-filled form. |
53
+
54
+ There is one size: the horizontal tab row is 32px tall.
55
+
56
+ ## Behaviour and accessibility
57
+
58
+ Built in:
59
+
60
+ - Tab moves focus to the selected tab; the next Tab moves into the panel.
61
+ - Left and Right arrows move between tabs (Up and Down when vertical). Disabled tabs are skipped.
62
+ - Screen readers announce the tabs, which one is selected, and the panel each controls.
63
+
64
+ Your job:
65
+
66
+ - Give each panel a heading or first line that matches its tab label, so people know where they landed.
67
+ - TODO: if a panel has no focusable content, keyboard users can't reach it with Tab. Confirm whether panels should take focus.
68
+
69
+ ## Tokens used
70
+
71
+ | Token | Where |
72
+ | --- | --- |
73
+ | `--color-base-foreground-inset` | Track behind the tabs (`default`) |
74
+ | `--color-base-foreground-card` | Selected tab background (`default`) |
75
+ | `--color-on-base-content-medium` | Unselected tab text |
76
+ | `--color-on-base-content-high` | Selected and hovered tab text; underline (`line`) |
77
+ | `--color-primary-border-strong` | Focus border and ring |
78
+ | `--radius-lg` (0.75rem) | Track corners |
79
+ | `--radius-md` (0.5rem) | Tab corners |
80
+
81
+ All color tokens have dark-mode values and switch automatically.
82
+
83
+ TODO: the selected tab's shadow is Tailwind's stock small shadow, not a lab-ds token.
84
+
85
+ TODO: shadcn's original gives the selected tab a border and a tinted fill in dark mode; lab-ds uses the same tokens in both modes. Check the dark-mode look against Figma.
86
+
87
+ ## Example
88
+
89
+ From the `Default` story:
90
+
91
+ ```tsx
92
+ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@bykhd/lab-ds"
93
+
94
+ <Tabs defaultValue="overview">
95
+ <TabsList>
96
+ <TabsTrigger value="overview">Overview</TabsTrigger>
97
+ <TabsTrigger value="activity">Activity</TabsTrigger>
98
+ <TabsTrigger value="settings">Settings</TabsTrigger>
99
+ </TabsList>
100
+ <TabsContent value="overview">12 pages, last edited today.</TabsContent>
101
+ <TabsContent value="activity">Mina renamed the project.</TabsContent>
102
+ <TabsContent value="settings">Project name, visibility, and members.</TabsContent>
103
+ </Tabs>
104
+ ```
105
+
106
+ The stories also show `Line`, `Vertical`, and `DisabledTab`.
107
+
108
+ ## References
109
+
110
+ [WAI-ARIA APG tabs pattern](https://www.w3.org/WAI/ARIA/apg/patterns/tabs/), [Base UI Tabs](https://base-ui.com/react/components/tabs), [Carbon tabs](https://carbondesignsystem.com/components/tabs/usage/), [GOV.UK tabs](https://design-system.service.gov.uk/components/tabs/).
111
+
112
+ TODO: these are common practice but weren't checked against a primary source: sentence-case labels, no nested tabs, not hiding required fields in tabs, and not reordering tabs.
@@ -0,0 +1,58 @@
1
+ # Textarea
2
+
3
+ A multi-line text box for longer answers such as a comment, a description, or notes.
4
+
5
+ ## When to use
6
+
7
+ - When the answer may be more than one line.
8
+ - When people need to see what they've written while they write it.
9
+
10
+ ## When not to use
11
+
12
+ - For short, single-line answers. Use `Input`.
13
+ - When the box needs buttons or a toolbar attached. Use `InputGroup` with `InputGroupTextarea`.
14
+
15
+ ## Rules
16
+
17
+ - Always give it a visible label (use `Field`, or `Label`). A placeholder is not a label.
18
+ - If there's a length limit, say so in the help text, and set it well above what most people need. TODO: lab-ds has no character counter yet.
19
+ - Show errors with `aria-invalid` and a `FieldError` message.
20
+
21
+ ## Props and variants
22
+
23
+ There are no visual variants and one size. It fills the width of its container, starts about three lines tall (64px), and grows as the user types.
24
+
25
+ It accepts every native textarea prop. The ones that change how it looks:
26
+
27
+ | Prop | Values | What it does |
28
+ | --- | --- | --- |
29
+ | `disabled` | `true`, `false` | Greyed out and can't be changed. |
30
+ | `aria-invalid` | `true`, `false` | Red border. |
31
+
32
+ ## Tokens used
33
+
34
+ | Token | Where |
35
+ | --- | --- |
36
+ | `--color-base-foreground-action` / `-hover` | Background, and on hover |
37
+ | `--color-on-base-border-default` | Border |
38
+ | `--color-on-base-content-high` | Text |
39
+ | `--color-on-base-content-low` | Placeholder |
40
+ | `--color-primary-border-strong` | Focus border and ring |
41
+ | `--color-base-foreground-disable`, `--color-on-base-border-disable`, `--color-on-base-content-low`, `--color-on-base-content-disable` | Disabled background, border, text, placeholder |
42
+ | `--color-danger-border-strong` / `--color-danger-border-default` | Invalid border, and on hover |
43
+ | `--radius-comp-input` (0.5rem) | Corners |
44
+
45
+ All color tokens have dark-mode values and switch automatically.
46
+
47
+ ## Example
48
+
49
+ From the `Default` story:
50
+
51
+ ```tsx
52
+ import { Label, Textarea } from "@bykhd/lab-ds"
53
+
54
+ <Label htmlFor="notes">Notes for reviewers</Label>
55
+ <Textarea id="notes" placeholder="What should reviewers look at first?" />
56
+ ```
57
+
58
+ The stories also show `Disabled` and `Invalid`.