@wso2/oxygen-ui 0.22.0 → 0.23.1

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.
package/.ai/AGENTS.md CHANGED
@@ -23,6 +23,9 @@ function App() {
23
23
  3. **Icons from `@wso2/oxygen-ui-icons-react`** - Separate package for icons
24
24
  4. **MUI X uses namespaces** - `DataGrid.DataGrid`, `DatePickers.DatePicker`, `TreeView.TreeView`
25
25
  5. **Use theme tokens** - Use `sx` prop with theme values, not hardcoded colors/spacing
26
+ 6. **Fixed labels on inputs** - Give every labelled `TextField` and `Select` `labelPlacement="top"`; never use MUI's floating label (`InputLabel` inside `FormControl`) in new code
27
+ - **`ComplexSelect` is the exception** - Pass `label` and keep the default `labelAnchor` (`inside`), which puts the label inside the field above the selected value. Do not set `labelAnchor="outside"` or `"border"` in new code
28
+ 7. **Select placeholders come from the developer** - Give every `Select` and `TextField select` a `placeholder`; ask the developer for the text instead of inventing it. Native selects (`native` or `SelectProps={{ native: true }}`) ignore `placeholder`, so put that same text in the empty option instead: `<option value="">Select a role</option>`
26
29
 
27
30
  ## Import Patterns
28
31
 
package/.ai/components.md CHANGED
@@ -987,7 +987,7 @@ import { PageContent } from '@wso2/oxygen-ui';
987
987
 
988
988
  ## ComplexSelect
989
989
 
990
- Enhanced select component with search and multi-select capabilities.
990
+ Select with rich options: icons, avatars, two-line text, list headers and dividers. Built on the MUI `Select`, so it accepts the `Select` props. Use it for the organization and project switchers in `Header.Switchers`.
991
991
 
992
992
  ```tsx
993
993
  import { ComplexSelect } from '@wso2/oxygen-ui';
@@ -997,27 +997,34 @@ import { ComplexSelect } from '@wso2/oxygen-ui';
997
997
 
998
998
  | Prop | Type | Default | Description |
999
999
  |------|------|---------|-------------|
1000
- | `options` | `Option[]` | required | Select options |
1001
- | `value` | `string \| string[]` | - | Selected value(s) |
1002
- | `onChange` | `(value) => void` | - | Change handler |
1003
- | `multiple` | `boolean` | `false` | Enable multi-select |
1004
- | `searchable` | `boolean` | `false` | Enable search |
1000
+ | `label` | `ReactNode` | - | Field label. Names the combobox |
1001
+ | `labelAnchor` | `'inside' \| 'outside' \| 'border'` | `'inside'` | Where the label sits. Keep the default in new code; `outside` and `border` are for existing screens only |
1002
+ | `size` | `'small' \| 'medium'` | `'small'` | Field size. A theme can change it with `components.MuiComplexSelect.defaultProps.size` |
1003
+ | `value` | `unknown` | - | Selected value |
1004
+ | `onChange` | `(event) => void` | - | Change handler |
1005
+ | `children` | `ReactNode` | required | `ComplexSelect.MenuItem`, `ComplexSelect.ListHeader` and `ComplexSelect.Divider` |
1006
+
1007
+ Sub-components: `ComplexSelect.MenuItem`, `ComplexSelect.MenuItem.Icon`, `ComplexSelect.MenuItem.Avatar`, `ComplexSelect.MenuItem.Text` (`primary`, `secondary`), `ComplexSelect.ListHeader`, `ComplexSelect.Divider`.
1005
1008
 
1006
1009
  ### Usage
1007
1010
 
1008
1011
  ```tsx
1009
- <ComplexSelect
1010
- options={[
1011
- { value: 'us', label: 'United States' },
1012
- { value: 'uk', label: 'United Kingdom' },
1013
- { value: 'ca', label: 'Canada' },
1014
- ]}
1015
- value={country}
1016
- onChange={setCountry}
1017
- searchable
1018
- />
1012
+ <ComplexSelect label="Organization" value={org} onChange={(e) => setOrg(e.target.value as string)}>
1013
+ <ComplexSelect.ListHeader>Organizations</ComplexSelect.ListHeader>
1014
+ <ComplexSelect.MenuItem value="acme">
1015
+ <ComplexSelect.MenuItem.Avatar>A</ComplexSelect.MenuItem.Avatar>
1016
+ <ComplexSelect.MenuItem.Text primary="Acme Corp" secondary="Owner" />
1017
+ </ComplexSelect.MenuItem>
1018
+ </ComplexSelect>
1019
1019
  ```
1020
1020
 
1021
+ ### Label
1022
+
1023
+ - With the default `labelAnchor`, `inside`, the label sits inside the field above the selected value. The field keeps the option's icon or avatar and hides its secondary text. It is 48px tall, so it fits the 64px `Header`.
1024
+ - Pass `label` and do not set `labelAnchor`. Do not wrap it in `FormControl` or add an `InputLabel`, `FormLabel` or `labelPlacement`.
1025
+ - Without a visible label, name it with `slotProps={{ input: { 'aria-label': 'Organization' } }}`.
1026
+ - For a chain of levels in the Header, use `ContextSwitcher`, which draws each level as a `ComplexSelect` with the label inside.
1027
+
1021
1028
  ---
1022
1029
 
1023
1030
  ## NotificationBanner
@@ -987,7 +987,7 @@ import { PageContent } from '@wso2/oxygen-ui';
987
987
 
988
988
  ## ComplexSelect
989
989
 
990
- Enhanced select component with search and multi-select capabilities.
990
+ Select with rich options: icons, avatars, two-line text, list headers and dividers. Built on the MUI `Select`, so it accepts the `Select` props. Use it for the organization and project switchers in `Header.Switchers`.
991
991
 
992
992
  ```tsx
993
993
  import { ComplexSelect } from '@wso2/oxygen-ui';
@@ -997,27 +997,34 @@ import { ComplexSelect } from '@wso2/oxygen-ui';
997
997
 
998
998
  | Prop | Type | Default | Description |
999
999
  |------|------|---------|-------------|
1000
- | `options` | `Option[]` | required | Select options |
1001
- | `value` | `string \| string[]` | - | Selected value(s) |
1002
- | `onChange` | `(value) => void` | - | Change handler |
1003
- | `multiple` | `boolean` | `false` | Enable multi-select |
1004
- | `searchable` | `boolean` | `false` | Enable search |
1000
+ | `label` | `ReactNode` | - | Field label. Names the combobox |
1001
+ | `labelAnchor` | `'inside' \| 'outside' \| 'border'` | `'inside'` | Where the label sits. Keep the default in new code; `outside` and `border` are for existing screens only |
1002
+ | `size` | `'small' \| 'medium'` | `'small'` | Field size. A theme can change it with `components.MuiComplexSelect.defaultProps.size` |
1003
+ | `value` | `unknown` | - | Selected value |
1004
+ | `onChange` | `(event) => void` | - | Change handler |
1005
+ | `children` | `ReactNode` | required | `ComplexSelect.MenuItem`, `ComplexSelect.ListHeader` and `ComplexSelect.Divider` |
1006
+
1007
+ Sub-components: `ComplexSelect.MenuItem`, `ComplexSelect.MenuItem.Icon`, `ComplexSelect.MenuItem.Avatar`, `ComplexSelect.MenuItem.Text` (`primary`, `secondary`), `ComplexSelect.ListHeader`, `ComplexSelect.Divider`.
1005
1008
 
1006
1009
  ### Usage
1007
1010
 
1008
1011
  ```tsx
1009
- <ComplexSelect
1010
- options={[
1011
- { value: 'us', label: 'United States' },
1012
- { value: 'uk', label: 'United Kingdom' },
1013
- { value: 'ca', label: 'Canada' },
1014
- ]}
1015
- value={country}
1016
- onChange={setCountry}
1017
- searchable
1018
- />
1012
+ <ComplexSelect label="Organization" value={org} onChange={(e) => setOrg(e.target.value as string)}>
1013
+ <ComplexSelect.ListHeader>Organizations</ComplexSelect.ListHeader>
1014
+ <ComplexSelect.MenuItem value="acme">
1015
+ <ComplexSelect.MenuItem.Avatar>A</ComplexSelect.MenuItem.Avatar>
1016
+ <ComplexSelect.MenuItem.Text primary="Acme Corp" secondary="Owner" />
1017
+ </ComplexSelect.MenuItem>
1018
+ </ComplexSelect>
1019
1019
  ```
1020
1020
 
1021
+ ### Label
1022
+
1023
+ - With the default `labelAnchor`, `inside`, the label sits inside the field above the selected value. The field keeps the option's icon or avatar and hides its secondary text. It is 48px tall, so it fits the 64px `Header`.
1024
+ - Pass `label` and do not set `labelAnchor`. Do not wrap it in `FormControl` or add an `InputLabel`, `FormLabel` or `labelPlacement`.
1025
+ - Without a visible label, name it with `slotProps={{ input: { 'aria-label': 'Organization' } }}`.
1026
+ - For a chain of levels in the Header, use `ContextSwitcher`, which draws each level as a `ComplexSelect` with the label inside.
1027
+
1021
1028
  ---
1022
1029
 
1023
1030
  ## NotificationBanner
@@ -12,7 +12,8 @@ description: Generate forms with Form.* components and validation. Use when crea
12
12
  3. Use `Form.Stack` for field layout
13
13
  4. Give every field a fixed label on top with `labelPlacement="top"` (see Field Labels)
14
14
  5. Mark each required field with `required`; leave optional fields unmarked
15
- 6. Add validation with `error` and `helperText` props
15
+ 6. Give every select a `placeholder`; ask the developer for the text (see Select and Autocomplete)
16
+ 7. Add validation with `error` and `helperText` props. Plain `Select` has no `helperText`, so use `TextField select` for any select that shows validation messages
16
17
 
17
18
  ## Critical Rules
18
19
 
@@ -59,10 +60,10 @@ Forms use a fixed label above the input, not MUI's floating label. `labelPlaceme
59
60
 
60
61
  ### Select and Autocomplete
61
62
 
62
- The same rules apply. Use `TextField` with `select`, or pass `labelPlacement="top"` and `required` to the `TextField` in `renderInput`:
63
+ The same rules apply. Use `TextField` with `select` (it supports `helperText` for validation messages), or `Select` with `labelPlacement="top"` (see the `oxygen-select` skill). Every select needs a `placeholder`; ask the developer for the text before writing the form, listing each select with a suggestion such as "Select a role", and never invent it. Native selects ignore `placeholder`, so use that text as the empty option's label instead. A select in error keeps its label colour; the error shows on the border and in `helperText`. For Autocomplete, pass `labelPlacement="top"` and `required` to the `TextField` in `renderInput`:
63
64
 
64
65
  ```tsx
65
- <TextField select labelPlacement="top" label="Role" required value={role} onChange={...}>
66
+ <TextField select labelPlacement="top" label="Role" placeholder="Select a role" required value={role} onChange={...}>
66
67
  <MenuItem value="developer">Developer</MenuItem>
67
68
  </TextField>
68
69
 
@@ -178,7 +179,9 @@ function SectionedForm() {
178
179
  <Form.Stack spacing={2}>
179
180
  {/* Optional fields: no marker */}
180
181
  <TextField fullWidth labelPlacement="top" label="Company name" />
181
- <TextField fullWidth select labelPlacement="top" label="Role" defaultValue="">
182
+ {/* Placeholder text comes from the developer */}
183
+ <TextField fullWidth select labelPlacement="top" label="Role" placeholder="Select a role" defaultValue="">
184
+ {/* Optional select: an empty option lets users clear it */}
182
185
  <MenuItem value="">None</MenuItem>
183
186
  <MenuItem value="developer">Developer</MenuItem>
184
187
  <MenuItem value="designer">Designer</MenuItem>
@@ -311,8 +311,21 @@ export default App;
311
311
  </Header.Brand>
312
312
 
313
313
  <Header.Switchers>
314
- <OrganizationSwitcher />
315
- <ProjectSwitcher />
314
+ <ComplexSelect label="Organization" value={org} onChange={(e) => setOrg(e.target.value as string)}>
315
+ {organizations.map((o) => (
316
+ <ComplexSelect.MenuItem key={o.id} value={o.id}>
317
+ <ComplexSelect.MenuItem.Avatar>{o.initial}</ComplexSelect.MenuItem.Avatar>
318
+ <ComplexSelect.MenuItem.Text primary={o.name} secondary={o.role} />
319
+ </ComplexSelect.MenuItem>
320
+ ))}
321
+ </ComplexSelect>
322
+ <ComplexSelect label="Project" value={project} onChange={(e) => setProject(e.target.value as string)}>
323
+ {projects.map((p) => (
324
+ <ComplexSelect.MenuItem key={p.id} value={p.id}>
325
+ <ComplexSelect.MenuItem.Text primary={p.name} />
326
+ </ComplexSelect.MenuItem>
327
+ ))}
328
+ </ComplexSelect>
316
329
  </Header.Switchers>
317
330
 
318
331
  <Header.Spacer />
@@ -326,6 +339,8 @@ export default App;
326
339
  </Header>
327
340
  ```
328
341
 
342
+ Switchers use `ComplexSelect` with a `label` and the default `labelAnchor`, `inside`: the label sits inside the field above the selected value. Do not set `labelAnchor`; `outside` and `border` are for existing screens only, and they make the field too tall for the 64px Header. Keep the default `size` (`small`); the field is 48px tall. For a chain of levels (organization, project, component), use `ContextSwitcher` instead, which draws each level the same way. See the `oxygen-select` skill.
343
+
329
344
  ## Minimal Header (No Switchers)
330
345
 
331
346
  ```tsx
@@ -0,0 +1,170 @@
1
+ ---
2
+ name: oxygen-select
3
+ description: Use the Oxygen UI Select with a fixed label above the field instead of MUI's floating label, and a placeholder the developer provides. Use ComplexSelect with its default inside label. Use when adding or editing any Select, ComplexSelect, dropdown, or picker built on Select, or when converting FormControl + InputLabel + Select code to fixed labels.
4
+ ---
5
+
6
+ # Fixed-Label Select
7
+
8
+ Oxygen UI selects use a fixed label that sits above the field and never moves. Do not use MUI's floating label, which starts inside the field and shrinks into the border on focus. The floating variant still works, but only for existing screens; never write new code with it.
9
+
10
+ ```text
11
+ Fixed label (use) Floating label (don't use)
12
+ Environment ┌─ Environment ───────┐
13
+ ┌─────────────────────┐ │ Production ▾ │
14
+ │ Production ▾ │ └─────────────────────┘
15
+ └─────────────────────┘
16
+ ```
17
+
18
+ ## Instructions
19
+
20
+ 1. Import `Select` from `@wso2/oxygen-ui`, never from `@mui/material`. `labelPlacement` is an Oxygen UI prop, and the MUI `Select` ignores it.
21
+ 2. Add `labelPlacement="top"` and `label` to every `Select`. Do not wrap it in `FormControl` or add an `InputLabel`; the component draws its own.
22
+ 3. Give every `Select` a `placeholder`. Get the text from the developer; never make it up (see Placeholder text).
23
+ 4. Mark required selects with `required`; the theme draws the `*`.
24
+ 5. When the select needs helper text or validation messages, use `TextField select labelPlacement="top"` instead (see the `oxygen-textfield` skill). It has the same fixed label, supports `helperText`, and takes the same `placeholder`.
25
+ 6. For forms (validation, sections, wizards), also follow the `oxygen-form` skill.
26
+
27
+ ## Usage
28
+
29
+ ```tsx
30
+ import { Select, MenuItem } from '@wso2/oxygen-ui';
31
+
32
+ <Select
33
+ labelPlacement="top"
34
+ label="Environment"
35
+ placeholder="Select an environment"
36
+ required
37
+ value={env}
38
+ onChange={(e) => setEnv(e.target.value)}
39
+ >
40
+ <MenuItem value="dev">Development</MenuItem>
41
+ <MenuItem value="prod">Production</MenuItem>
42
+ </Select>
43
+ ```
44
+
45
+ With helper text:
46
+
47
+ ```tsx
48
+ import { TextField, MenuItem } from '@wso2/oxygen-ui';
49
+
50
+ <TextField
51
+ select
52
+ labelPlacement="top"
53
+ label="Environment"
54
+ placeholder="Select an environment"
55
+ helperText="Where the component is deployed."
56
+ value={env}
57
+ onChange={(e) => setEnv(e.target.value)}
58
+ >
59
+ <MenuItem value="dev">Development</MenuItem>
60
+ <MenuItem value="prod">Production</MenuItem>
61
+ </TextField>
62
+ ```
63
+
64
+ ## Placeholder text
65
+
66
+ Every select shows a placeholder while nothing is selected. The developer owns this text, so ask for it.
67
+
68
+ 1. Before writing the code, check whether the developer has given placeholder text for each select.
69
+ 2. If any is missing, ask the developer once, listing every select that needs one by its label. Offer a suggestion for each so they can accept or change it, for example:
70
+
71
+ ```text
72
+ Placeholder text needed for these selects. Reply with your text, or "ok" to use the suggestions:
73
+ - Environment: "Select an environment"
74
+ - Region: "Select a region"
75
+ ```
76
+
77
+ 3. Use the developer's text exactly as given. Do not write code with placeholder text the developer has not provided or accepted.
78
+ 4. If you can't ask (for example, in a non-interactive run), use the suggestions and list them in your summary so the developer can review them.
79
+
80
+ Suggestions follow these rules:
81
+
82
+ - Start with "Select" and name the thing chosen, in sentence case: "Select a region", not "Select Region" or "Choose…"
83
+ - No trailing punctuation or ellipsis
84
+ - Don't repeat "(Optional)" or "*" from the label
85
+ - Never use the placeholder in place of a label
86
+
87
+ ## How it behaves
88
+
89
+ - The label renders as a `FormLabel` above the select and keeps its colour on focus and in the error state; the error shows on the field's border and in helper text. Focus shows only on the field: in the Choreo Labs theme, a text-colour border with a Cobalt ring, the same as fixed-label text fields.
90
+ - The label names the combobox through `labelId` (or `htmlFor` with `native`), so screen readers announce it. Do not add your own `aria-label` when a label is set.
91
+ - `sx`, `className`, `style`, `fullWidth` and `ref` apply to the outer wrapper that holds the label and the select. `size`, `variant`, `required`, `error` and `disabled` apply to both.
92
+ - `placeholder` shows text in the field while nothing is selected (an empty value: `''`, `null`, `undefined` or `[]`), in the secondary text colour so it meets contrast requirements. It works with a custom `renderValue`. Native selects ignore it, so give them an empty option with the developer's placeholder text instead: `<option value="">Select a role</option>`.
93
+ - Without a `label`, the prop has no effect and the select renders as a plain MUI `Select`.
94
+
95
+ ## ComplexSelect: keep the label inside
96
+
97
+ `ComplexSelect` (rich options with icons, avatars and list headers, such as the organization and project switchers in `Header.Switchers`) follows a different rule from `Select`. Its label sits inside the field, above the selected value. This is the default `labelAnchor`, `inside`.
98
+
99
+ 1. Pass `label` and do not set `labelAnchor`. The default is `inside`.
100
+ 2. Do not use `labelAnchor="outside"` or `labelAnchor="border"` in new code. They are kept for existing screens only. When you edit a `ComplexSelect` that sets either, ask the developer before changing it, as the field's height changes.
101
+ 3. Do not add `labelPlacement`, `FormControl`, `InputLabel` or a `FormLabel` around it. `ComplexSelect` draws and links its own label.
102
+ 4. Do not add your own `aria-label` when a label is set. The label names the combobox.
103
+ 5. Leave `size` at its default, `small`. With the label inside, the field is 48px tall and fits the 64px `Header` with 8px above and below.
104
+ 6. For a chain of levels in the Header (organization, then project, then component), use `ContextSwitcher`, which draws each level as a `ComplexSelect` with the label inside.
105
+
106
+ ```tsx
107
+ import { ComplexSelect } from '@wso2/oxygen-ui';
108
+
109
+ <ComplexSelect label="Organization" value={org} onChange={(e) => setOrg(e.target.value as string)}>
110
+ <ComplexSelect.MenuItem value="acme">
111
+ <ComplexSelect.MenuItem.Avatar>A</ComplexSelect.MenuItem.Avatar>
112
+ <ComplexSelect.MenuItem.Text primary="Acme Corp" secondary="Owner" />
113
+ </ComplexSelect.MenuItem>
114
+ </ComplexSelect>
115
+ ```
116
+
117
+ The field shows the label, then the selected option with its icon or avatar. Secondary text appears only in the open list.
118
+
119
+ ```text
120
+ ✓ <ComplexSelect label="Organization" …> label inside, the default
121
+ ✗ <ComplexSelect label="Organization" labelAnchor="outside" …> existing screens only
122
+ ✗ <ComplexSelect label="Organization" labelAnchor="border" …> existing screens only
123
+ ✗ <ComplexSelect slotProps={{ input: { 'aria-label': 'Organization' } }} …> hidden name where a visible label fits
124
+ ```
125
+
126
+ ## Selects with no visible label
127
+
128
+ Some selects have no visible label, such as a sort or page-size picker in a toolbar. Omit `label`, give the select an accessible name, and still ask the developer for a placeholder if the select can be empty:
129
+
130
+ ```tsx
131
+ <Select placeholder="Sort by" value={sort} onChange={(e) => setSort(e.target.value)} inputProps={{ 'aria-label': 'Sort by' }}>
132
+ <MenuItem value="name">Name</MenuItem>
133
+ <MenuItem value="date">Date</MenuItem>
134
+ </Select>
135
+ ```
136
+
137
+ Never use a floating label to save vertical space.
138
+
139
+ ## Converting floating labels
140
+
141
+ When you edit code that uses floating labels:
142
+
143
+ | Floating-label code | Fixed-label replacement |
144
+ | --- | --- |
145
+ | `import { Select } from '@mui/material'` | `import { Select } from '@wso2/oxygen-ui'` |
146
+ | `<FormControl><InputLabel id="x">Role</InputLabel><Select labelId="x" label="Role">…</Select></FormControl>` | `<Select labelPlacement="top" label="Role">…</Select>` |
147
+ | The same, plus a `FormHelperText` | `<TextField select labelPlacement="top" label="Role" helperText="…">…</TextField>` |
148
+ | `<FormControl sx={{ minWidth: 200 }}>` around the select | Move `sx` onto the `Select` |
149
+ | `<FormControl error required>` around the select | Move `error` and `required` onto the `Select` |
150
+ | A `Typography` or `FormLabel` placed above a label-less `Select` | Remove it; pass the text as `label` with `labelPlacement="top"` |
151
+ | `label="Role *"` | `label="Role" required` |
152
+ | `<MenuItem value="" disabled>Select a role</MenuItem>` used as a placeholder | Remove it; pass `placeholder="Select a role"` |
153
+ | `displayEmpty` with a `renderValue` that returns placeholder text | Remove both; pass `placeholder` (keep a `renderValue` that formats real values) |
154
+ | A select with no placeholder | Ask the developer for the text, then add `placeholder` |
155
+
156
+ ## Do and don't
157
+
158
+ ```text
159
+ ✓ <Select labelPlacement="top" label="Role" placeholder="Select a role" required value={role} onChange={…}>…</Select>
160
+ ✓ <TextField select labelPlacement="top" label="Role" placeholder="Select a role" helperText="…">…</TextField>
161
+ ✗ <Select labelPlacement="top" label="Role" value={role}>…</Select> no placeholder; ask the developer for one
162
+ ✗ <MenuItem value="" disabled>Select a role</MenuItem> fake placeholder option
163
+ ✗ <FormControl><InputLabel>Role</InputLabel><Select label="Role"> floating label
164
+ ✗ import { Select } from '@mui/material' labelPlacement is ignored
165
+ ✗ <FormControl><Select labelPlacement="top" label="Role" /></FormControl> extra wrapper; the Select has its own
166
+ ✗ <Typography>Role</Typography><Select /> label not linked to the select
167
+ ✗ <Select labelPlacement="top" label="Role *" /> hand-written asterisk
168
+ ```
169
+
170
+ Write labels in sentence case, for example "Deployment region", not "Deployment Region".
@@ -0,0 +1,91 @@
1
+ ---
2
+ name: oxygen-textfield
3
+ description: Use the Oxygen UI TextField with a fixed label above the field instead of MUI's floating label. Use when adding or editing any TextField, select, or Autocomplete input, or when converting floating-label fields to fixed labels.
4
+ ---
5
+
6
+ # Fixed-Label TextField
7
+
8
+ Oxygen UI text inputs use a fixed label that sits above the field and never moves. Do not use MUI's floating label, which starts inside the field and shrinks into the border on focus.
9
+
10
+ ```text
11
+ Fixed label (use) Floating label (don't use)
12
+ Display name ┌─ Display name ──────┐
13
+ ┌─────────────────────┐ │ my-app │
14
+ │ my-app │ └─────────────────────┘
15
+ └─────────────────────┘
16
+ ```
17
+
18
+ ## Instructions
19
+
20
+ 1. Import `TextField` from `@wso2/oxygen-ui`, never from `@mui/material`. `labelPlacement` is an Oxygen UI prop, and the MUI `TextField` ignores it.
21
+ 2. Add `labelPlacement="top"` to every `TextField` that has a `label`.
22
+ 3. Apply the same rule to selects (`TextField select`) and to the `TextField` in an Autocomplete's `renderInput`. Every `TextField select` also needs a `placeholder` whose text the developer provides; follow the `oxygen-select` skill for selects. Native selects (`SelectProps={{ native: true }}`) ignore `placeholder`, so use that text as the empty `<option value="">` instead.
23
+ 4. Mark required fields with `required`; the theme draws the `*`.
24
+ 5. For forms (validation, sections, wizards), also follow the `oxygen-form` skill.
25
+
26
+ ## Usage
27
+
28
+ ```tsx
29
+ import { TextField, MenuItem, Autocomplete } from '@wso2/oxygen-ui';
30
+
31
+ <TextField labelPlacement="top" label="Display name" required />
32
+
33
+ <TextField select labelPlacement="top" label="Environment" placeholder="Select an environment" value={env} onChange={(e) => setEnv(e.target.value)}>
34
+ <MenuItem value="dev">Development</MenuItem>
35
+ <MenuItem value="prod">Production</MenuItem>
36
+ </TextField>
37
+
38
+ <Autocomplete
39
+ options={regions}
40
+ renderInput={(params) => <TextField {...params} labelPlacement="top" label="Region" />}
41
+ />
42
+ ```
43
+
44
+ ## How it behaves
45
+
46
+ - The label renders as a `FormLabel` above the input and keeps its colour on focus. Focus shows only on the field's border.
47
+ - The label is linked to the input with `htmlFor`, and for selects through `labelId`, so screen readers announce it. Do not add your own `aria-label` when a label is set.
48
+ - `sx`, `className`, `style`, `fullWidth`, `margin` and `ref` apply to the outer wrapper that holds the label and the field.
49
+ - When `error` is set, an empty helper line is reserved so the layout doesn't shift when a message appears.
50
+ - Without a `label`, the prop has no effect and the field renders as a plain MUI `TextField`.
51
+
52
+ ## Fields with no visible label
53
+
54
+ Some fields have no visible label, such as a search box in a toolbar or a table filter. Omit `label`, describe the field with a `placeholder`, and give it an accessible name:
55
+
56
+ ```tsx
57
+ <TextField
58
+ placeholder="Search projects"
59
+ slotProps={{ htmlInput: { 'aria-label': 'Search projects' } }}
60
+ />
61
+ ```
62
+
63
+ Never use a floating label to save vertical space.
64
+
65
+ ## Converting floating labels
66
+
67
+ When you edit code that uses floating labels:
68
+
69
+ | Floating-label code | Fixed-label replacement |
70
+ | --- | --- |
71
+ | `import { TextField } from '@mui/material'` | `import { TextField } from '@wso2/oxygen-ui'` |
72
+ | `<TextField label="Name" />` | `<TextField labelPlacement="top" label="Name" />` |
73
+ | `InputLabelProps={{ shrink: true }}` or `slotProps={{ inputLabel: { shrink: true } }}` | Remove it; add `labelPlacement="top"` |
74
+ | `<FormControl><InputLabel>Role</InputLabel><Select label="Role">` | `<Select labelPlacement="top" label="Role" placeholder="Select a role">` or `<TextField select labelPlacement="top" label="Role" placeholder="Select a role">`, with placeholder text from the developer (see `oxygen-select`) |
75
+ | A `Typography` or `FormLabel` placed above a label-less `TextField` | Remove it; pass the text as `label` with `labelPlacement="top"` |
76
+ | `label="Email *"` | `label="Email" required` |
77
+
78
+ ## Do and don't
79
+
80
+ ```text
81
+ ✓ <TextField labelPlacement="top" label="Email" required />
82
+ ✓ <TextField select labelPlacement="top" label="Role" placeholder="Select a role">…</TextField>
83
+ ✗ <TextField label="Email" /> floating label
84
+ ✗ import { TextField } from '@mui/material' labelPlacement is ignored
85
+ ✗ <TextField label="Email" slotProps={{ inputLabel: { shrink: true } }} />
86
+ ✗ <InputLabel>Role</InputLabel><Select label="Role"> floating select label
87
+ ✗ <Typography>Email</Typography><TextField /> label not linked to the input
88
+ ✗ <TextField labelPlacement="top" label="Email *" /> hand-written asterisk
89
+ ```
90
+
91
+ Write labels in sentence case, for example "Display name", not "Display Name".
package/README.md CHANGED
@@ -466,6 +466,8 @@ Creates:
466
466
  - `/oxygen-component` - Generate Oxygen UI components
467
467
  - `/oxygen-layout` - Generate app layouts
468
468
  - `/oxygen-form` - Generate forms with validation
469
+ - `/oxygen-textfield` - Use fixed-label text fields instead of floating labels
470
+ - `/oxygen-select` - Use fixed-label selects instead of floating labels
469
471
  - `/oxygen-migrate` - Migrate MUI code
470
472
  - Updates root `CLAUDE.md` with reference
471
473
 
package/bin/cli.js CHANGED
@@ -414,6 +414,8 @@ function initClaude(includeInternal = false) {
414
414
  console.log(' - /oxygen-component Generate Oxygen UI components');
415
415
  console.log(' - /oxygen-layout Generate app layouts');
416
416
  console.log(' - /oxygen-form Generate forms with validation');
417
+ console.log(' - /oxygen-textfield Use fixed-label text fields');
418
+ console.log(' - /oxygen-select Use fixed-label selects');
417
419
  console.log(' - /oxygen-migrate Migrate MUI code to Oxygen UI');
418
420
  if (includeInternal) {
419
421
  console.log(' - /oxygen-sync Sync AI docs with source (internal)');
@@ -548,6 +550,8 @@ Available Skills (Claude mode only):
548
550
  /oxygen-component Generate Oxygen UI React components
549
551
  /oxygen-layout Generate app layouts with AppShell
550
552
  /oxygen-form Generate forms with validation
553
+ /oxygen-textfield Use fixed-label text fields
554
+ /oxygen-select Use fixed-label selects
551
555
  /oxygen-migrate Migrate existing MUI code
552
556
  `);
553
557
  }
@@ -42,7 +42,8 @@ export interface AppBreadcrumbsProps extends React.HTMLAttributes<HTMLDivElement
42
42
  */
43
43
  maxItems?: number;
44
44
  /**
45
- * Separator between items. Defaults to a chevron.
45
+ * Separator between items. Defaults to a chevron, unless the theme sets
46
+ * `components.MuiAppBreadcrumbs.defaultProps.separator`.
46
47
  */
47
48
  separator?: ReactNode;
48
49
  /**
@@ -50,7 +51,7 @@ export interface AppBreadcrumbsProps extends React.HTMLAttributes<HTMLDivElement
50
51
  */
51
52
  sx?: SxProps<Theme>;
52
53
  }
53
- declare function AppBreadcrumbs({ items, maxItems, separator, sx, ...props }: AppBreadcrumbsProps): JSX.Element;
54
+ declare function AppBreadcrumbs(inProps: AppBreadcrumbsProps): JSX.Element;
54
55
  declare namespace AppBreadcrumbs {
55
56
  var displayName: string;
56
57
  }
@@ -7,14 +7,29 @@ export interface ComplexSelectProps extends Omit<SelectProps, 'children'> {
7
7
  children: ReactNode;
8
8
  /**
9
9
  * The anchor position of the label when provided.
10
- * - 'outside': Label appears above the select (default)
11
- * - 'inside': Label appears inside the select field above the selected value.
12
- * Icons are preserved but secondary text is automatically hidden for a cleaner display.
10
+ * - 'inside' (default): Label appears inside the select field above the selected value.
11
+ * Icons are preserved but secondary text is automatically hidden for a cleaner, more compact display.
12
+ * - 'outside': Label appears above the select
13
13
  * - 'border': Label appears on the border (MUI standard behavior)
14
+ * @default 'inside'
14
15
  */
15
16
  labelAnchor?: 'outside' | 'inside' | 'border';
17
+ /**
18
+ * The size of the field. Defaults to `small`, whatever the theme sets for `Select`, so
19
+ * switchers fit the Header. A theme can change it with
20
+ * `components.MuiComplexSelect.defaultProps.size`.
21
+ * @default 'small'
22
+ */
23
+ size?: SelectProps['size'];
16
24
  }
17
- export declare function ComplexSelect({ children, sx, label, labelId, labelAnchor, ...props }: ComplexSelectProps): import("react/jsx-runtime").JSX.Element;
25
+ /**
26
+ * Select with rich options: icons, avatars, two-line text, list headers and dividers.
27
+ *
28
+ * With a `label` and the default `labelAnchor` (`inside`), the label is drawn inside the field
29
+ * above the selected value and names the combobox through a visually hidden element. Without a
30
+ * label, pass a name through `slotProps.input['aria-label']`.
31
+ */
32
+ export declare function ComplexSelect(inProps: ComplexSelectProps): import("react/jsx-runtime").JSX.Element;
18
33
  interface ComplexSelectComponent {
19
34
  (props: ComplexSelectProps): ReactElement;
20
35
  ListHeader: typeof ComplexSelectListHeader;
@@ -0,0 +1,23 @@
1
+ import * as React from 'react';
2
+ import { type SelectProps as MuiSelectProps } from '@mui/material/Select';
3
+ /** `top` draws a static label above the select instead of MUI's floating label. */
4
+ export type SelectLabelPlacement = 'top';
5
+ export type SelectProps<Value = unknown> = MuiSelectProps<Value> & {
6
+ /** Leave unset for MUI's floating label; `top` draws a static label above the select. */
7
+ labelPlacement?: SelectLabelPlacement;
8
+ /** Shown in the field while nothing is selected. Ignored by `native` selects. */
9
+ placeholder?: React.ReactNode;
10
+ };
11
+ /** Select props that show `placeholder` while the value is empty; shared with `TextField select`. */
12
+ export declare function selectPlaceholderProps<Value>(placeholder: React.ReactNode, renderValue: ((value: Value) => React.ReactNode) | undefined, children: React.ReactNode): {
13
+ displayEmpty: boolean;
14
+ renderValue: (selected: Value) => string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
15
+ };
16
+ type SelectComponent = (<Value = unknown>(props: SelectProps<Value> & {
17
+ ref?: React.Ref<HTMLDivElement>;
18
+ }) => React.JSX.Element) & {
19
+ muiName: string;
20
+ };
21
+ /** MUI's Select; with `labelPlacement="top"`, `ref` and layout props go to an outer FormControl. */
22
+ declare const Select: SelectComponent;
23
+ export default Select;
@@ -0,0 +1,2 @@
1
+ export { default } from './Select';
2
+ export * from './Select';
@@ -38,6 +38,8 @@ export { default as RelativeTime } from './RelativeTime';
38
38
  export type { RelativeTimeProps } from './RelativeTime';
39
39
  export { default as TextField } from './TextField';
40
40
  export type { TextFieldProps, TextFieldLabelPlacement } from './TextField';
41
+ export { default as Select } from './Select';
42
+ export type { SelectProps, SelectLabelPlacement } from './Select';
41
43
  export { default as StatCard } from './StatCard';
42
44
  export type { StatCardProps } from './StatCard';
43
45
  export { default as TrialBadge, getTrialBadgeStatus } from './TrialBadge';
package/dist/index.d.ts CHANGED
@@ -25,8 +25,8 @@ export { default as Layout } from "./layouts";
25
25
  export * from "./animations";
26
26
  export * from "./hooks";
27
27
  export * from "./utils";
28
- export { TextField } from './components';
29
- export type { TextFieldProps, TextFieldLabelPlacement } from './components';
28
+ export { TextField, Select } from './components';
29
+ export type { TextFieldProps, TextFieldLabelPlacement, SelectProps, SelectLabelPlacement } from './components';
30
30
  export * from '@mui/material';
31
31
  export * as colors from '@mui/material/colors';
32
32
  export * as DataGrid from '@mui/x-data-grid';