@czi-sds/mcp 0.15.0 → 0.17.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.
- package/README.md +2 -1
- package/data/component-docs/Accordion.md +291 -0
- package/data/component-docs/Autocomplete.md +525 -0
- package/data/component-docs/Banner.md +231 -0
- package/data/component-docs/Button.md +224 -0
- package/data/component-docs/ButtonDropdown.md +256 -0
- package/data/component-docs/ButtonGroup.md +320 -0
- package/data/component-docs/ButtonToggle.md +397 -0
- package/data/component-docs/Callout.md +268 -0
- package/data/component-docs/CellBasic.md +122 -0
- package/data/component-docs/CellComponent.md +63 -0
- package/data/component-docs/CellHeader.md +128 -0
- package/data/component-docs/ComplexFilter.md +294 -0
- package/data/component-docs/ContentCard.md +406 -0
- package/data/component-docs/Dialog.md +651 -0
- package/data/component-docs/Dropdown.md +155 -0
- package/data/component-docs/DropdownMenu.md +949 -0
- package/data/component-docs/HeatmapChart.md +782 -0
- package/data/component-docs/Hero.md +363 -0
- package/data/component-docs/Icon.md +283 -0
- package/data/component-docs/InputCheckbox.md +205 -0
- package/data/component-docs/InputDropdown.md +482 -0
- package/data/component-docs/InputRadio.md +173 -0
- package/data/component-docs/InputSearch.md +81 -0
- package/data/component-docs/InputSlider.md +189 -0
- package/data/component-docs/InputText.md +110 -0
- package/data/component-docs/InputToggle.md +141 -0
- package/data/component-docs/IntentMessage.md +293 -0
- package/data/component-docs/Legend.md +442 -0
- package/data/component-docs/Link.md +23 -0
- package/data/component-docs/List.md +300 -0
- package/data/component-docs/LoadingIndicator.md +198 -0
- package/data/component-docs/Menu.md +298 -0
- package/data/component-docs/MenuItem.md +100 -0
- package/data/component-docs/NavigationFooter.md +165 -0
- package/data/component-docs/NavigationHeader.md +500 -0
- package/data/component-docs/NavigationJumpTo.md +414 -0
- package/data/component-docs/Notification.md +288 -0
- package/data/component-docs/Pagination.md +67 -0
- package/data/component-docs/Panel.md +636 -0
- package/data/component-docs/Popover.md +448 -0
- package/data/component-docs/PreComposedTable.md +2947 -0
- package/data/component-docs/SegmentedControl.md +396 -0
- package/data/component-docs/StackedBarChart.md +475 -0
- package/data/component-docs/Table.md +2000 -0
- package/data/component-docs/TableHeader.md +53 -0
- package/data/component-docs/TableRow.md +74 -0
- package/data/component-docs/Tabs.md +455 -0
- package/data/component-docs/Tag.md +647 -0
- package/data/component-docs/TagFilter.md +131 -0
- package/data/component-docs/Tooltip.md +561 -0
- package/data/component-docs/TooltipCondensed.md +203 -0
- package/data/component-docs/TooltipTable.md +145 -0
- package/data/component-docs/index.json +262 -0
- package/data/component-list.json +2 -5
- package/data/component-props/Accordion.json +31 -11
- package/data/component-props/Alert.json +3 -3
- package/data/component-props/Autocomplete.json +150 -15
- package/data/component-props/Banner.json +31 -17
- package/data/component-props/Button.json +45 -20
- package/data/component-props/ButtonDropdown.json +36 -17
- package/data/component-props/ButtonDropdownLegacy.json +11 -11
- package/data/component-props/ButtonGroup.json +32 -11
- package/data/component-props/ButtonIcon.json +10 -10
- package/data/component-props/ButtonLegacy.json +19 -19
- package/data/component-props/ButtonToggle.json +32 -19
- package/data/component-props/ButtonToggleLegacy.json +11 -11
- package/data/component-props/Callout.json +58 -17
- package/data/component-props/CellBasic.json +94 -41
- package/data/component-props/CellComponent.json +23 -7
- package/data/component-props/CellHeader.json +62 -19
- package/data/component-props/ComplexFilter.json +52 -21
- package/data/component-props/ContentCard.json +70 -47
- package/data/component-props/Dialog.json +47 -14
- package/data/component-props/Dropdown.json +67 -31
- package/data/component-props/DropdownMenu.json +128 -23
- package/data/component-props/HeatmapChart.json +88 -12
- package/data/component-props/Hero.json +80 -39
- package/data/component-props/Icon.json +20 -9
- package/data/component-props/InputCheckbox.json +36 -14
- package/data/component-props/InputDropdown.json +75 -27
- package/data/component-props/InputRadio.json +31 -13
- package/data/component-props/InputSearch.json +41 -18
- package/data/component-props/InputSlider.json +46 -19
- package/data/component-props/InputText.json +26 -19
- package/data/component-props/InputToggle.json +26 -9
- package/data/component-props/IntentMessage.json +38 -9
- package/data/component-props/Link.json +13 -7
- package/data/component-props/LoadingIndicator.json +11 -3
- package/data/component-props/MenuItem.json +38 -19
- package/data/component-props/MenuSelect.json +8 -8
- package/data/component-props/NavigationFooter.json +49 -19
- package/data/component-props/NavigationHeader.json +150 -37
- package/data/component-props/NavigationJumpTo.json +33 -7
- package/data/component-props/Notification.json +39 -21
- package/data/component-props/Pagination.json +39 -11
- package/data/component-props/Panel.json +62 -9
- package/data/component-props/Popover.json +80 -7
- package/data/component-props/PreComposedTable.json +99 -27
- package/data/component-props/SegmentedControl.json +42 -3
- package/data/component-props/StackedBarChart.json +116 -42
- package/data/component-props/TableRow.json +38 -19
- package/data/component-props/Tabs.json +66 -9
- package/data/component-props/Tag.json +34 -17
- package/data/component-props/TagFilter.json +10 -3
- package/data/component-props/Tooltip.json +49 -18
- package/data/component-props/TooltipCondensed.json +18 -9
- package/data/component-props/TooltipTable.json +17 -7
- package/data/resources/{zeroheight-rules.md → documentation-rules.md} +43 -30
- package/data/resources/figma-rules.md +2 -2
- package/dist/stdio.js +483 -780
- package/package.json +12 -8
- package/data/component-props/ButtonDropdownV2.json +0 -34
- package/data/component-props/ButtonNew.json +0 -47
- package/data/component-props/ButtonToggleV2.json +0 -44
- package/data/component-props/ButtonV2.json +0 -43
- package/data/zeroheight-cache.json +0 -10259
- package/data/zeroheight-exports/Accordion.md +0 -774
- package/data/zeroheight-exports/Banner.md +0 -691
- package/data/zeroheight-exports/Borders.md +0 -117
- package/data/zeroheight-exports/Buttons.md +0 -1854
- package/data/zeroheight-exports/Callout.md +0 -931
- package/data/zeroheight-exports/Colors.md +0 -1755
- package/data/zeroheight-exports/Content-Card.md +0 -309
- package/data/zeroheight-exports/Contributing-to-SDS.md +0 -98
- package/data/zeroheight-exports/Control-Inputs.md +0 -2818
- package/data/zeroheight-exports/Corners.md +0 -104
- package/data/zeroheight-exports/Cover-page.md +0 -3
- package/data/zeroheight-exports/Dialog.md +0 -1367
- package/data/zeroheight-exports/Downloads.md +0 -236
- package/data/zeroheight-exports/Drop-Shadows.md +0 -79
- package/data/zeroheight-exports/Dropdown-Input.md +0 -1776
- package/data/zeroheight-exports/Dropdown-Menus.md +0 -913
- package/data/zeroheight-exports/Element-Status-Tracker.md +0 -267
- package/data/zeroheight-exports/Field-Inputs.md +0 -1405
- package/data/zeroheight-exports/Filters.md +0 -1111
- package/data/zeroheight-exports/Getting-Started.md +0 -1157
- package/data/zeroheight-exports/Hero.md +0 -414
- package/data/zeroheight-exports/Icons.md +0 -2067
- package/data/zeroheight-exports/Intent.md +0 -86
- package/data/zeroheight-exports/Introduction-to-Bases.md +0 -35
- package/data/zeroheight-exports/Introduction-to-Cells.md +0 -35
- package/data/zeroheight-exports/Introduction-to-DNA.md +0 -35
- package/data/zeroheight-exports/Introduction-to-Genes.md +0 -35
- package/data/zeroheight-exports/Introduction.md +0 -115
- package/data/zeroheight-exports/Link.md +0 -432
- package/data/zeroheight-exports/Lists.md +0 -986
- package/data/zeroheight-exports/Loading-Indicator.md +0 -41
- package/data/zeroheight-exports/Navigation.md +0 -1190
- package/data/zeroheight-exports/Notification.md +0 -1038
- package/data/zeroheight-exports/Panel.md +0 -1030
- package/data/zeroheight-exports/README.md +0 -122
- package/data/zeroheight-exports/Responsive-Design.md +0 -330
- package/data/zeroheight-exports/Search-Input.md +0 -91
- package/data/zeroheight-exports/Search.md +0 -822
- package/data/zeroheight-exports/Segmented-Control.md +0 -609
- package/data/zeroheight-exports/Spacing.md +0 -297
- package/data/zeroheight-exports/Table.md +0 -5345
- package/data/zeroheight-exports/Tabs.md +0 -1324
- package/data/zeroheight-exports/Tags.md +0 -1545
- package/data/zeroheight-exports/Text-Link.md +0 -268
- package/data/zeroheight-exports/Theming.md +0 -362
- package/data/zeroheight-exports/Tooltips.md +0 -2015
- package/data/zeroheight-exports/Typography.md +0 -800
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# Banner
|
|
2
|
+
|
|
3
|
+
## Source Code
|
|
4
|
+
|
|
5
|
+
The component's source code in the SDS codebase can be found [here](https://github.com/chanzuckerberg/sci-components/blob/main/packages/components/src/core/Banner/index.tsx).
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
**React TypeScript**
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { Banner } from "@czi-sds/components";
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Code examples
|
|
16
|
+
|
|
17
|
+
### Default Banner
|
|
18
|
+
|
|
19
|
+
This example has the minimum props needed for the Banner component.
|
|
20
|
+
|
|
21
|
+
**Example: DefaultBanner**
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { Banner } from "@czi-sds/components";
|
|
25
|
+
|
|
26
|
+
function App() {
|
|
27
|
+
return (
|
|
28
|
+
<div className="app">
|
|
29
|
+
<Banner sdsType="primary">
|
|
30
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
31
|
+
</Banner>
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default App;
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Persistent Banner
|
|
40
|
+
|
|
41
|
+
This example showcases a Banner component that cannot be closed or dismissed.
|
|
42
|
+
|
|
43
|
+
**Example: PersistentBanner**
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
import { Banner } from "@czi-sds/components";
|
|
47
|
+
|
|
48
|
+
function App() {
|
|
49
|
+
return (
|
|
50
|
+
<div className="app">
|
|
51
|
+
<Banner sdsType="primary" dismissible={false}>
|
|
52
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
53
|
+
</Banner>
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export default App;
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Controlling when the Banner closes
|
|
62
|
+
|
|
63
|
+
Left alone, the Banner keeps track of being dismissed and closes itself. The moment you pass `dismissed`, that becomes your job: the close button fires `onClose` and nothing else, so a Banner rendered with `dismissed={false}` will not close until you say so.
|
|
64
|
+
|
|
65
|
+
**Example: ControllingDismissal**
|
|
66
|
+
|
|
67
|
+
```tsx
|
|
68
|
+
// Left alone, the Banner closes itself and does not come back. Passing
|
|
69
|
+
// `dismissed` - even as `false` - hands that decision over: the close button
|
|
70
|
+
// then only fires `onClose`, and the Banner stays on screen until you set
|
|
71
|
+
// `dismissed` yourself, which also means you can bring it back.
|
|
72
|
+
|
|
73
|
+
import { Banner, Button } from "@czi-sds/components";
|
|
74
|
+
import { useState } from "react";
|
|
75
|
+
|
|
76
|
+
function App() {
|
|
77
|
+
const [dismissed, setDismissed] = useState(false);
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<div className="app">
|
|
81
|
+
<Banner
|
|
82
|
+
dismissed={dismissed}
|
|
83
|
+
onClose={() => setDismissed(true)}
|
|
84
|
+
sdsType="primary"
|
|
85
|
+
>
|
|
86
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
87
|
+
</Banner>
|
|
88
|
+
{dismissed && (
|
|
89
|
+
<Button
|
|
90
|
+
onClick={() => setDismissed(false)}
|
|
91
|
+
sdsStyle="minimal"
|
|
92
|
+
sdsType="primary"
|
|
93
|
+
>
|
|
94
|
+
Bring the banner back
|
|
95
|
+
</Button>
|
|
96
|
+
)}
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export default App;
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Secondary Banner
|
|
105
|
+
|
|
106
|
+
This example pairs a primary Banner with the secondary variant that follows it.
|
|
107
|
+
|
|
108
|
+
**Example: SecondaryBanner**
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
// The secondary variant, meant to follow a primary Banner
|
|
112
|
+
|
|
113
|
+
import { Banner } from "@czi-sds/components";
|
|
114
|
+
|
|
115
|
+
function App() {
|
|
116
|
+
return (
|
|
117
|
+
<div className="app">
|
|
118
|
+
<Banner sdsType="primary" intent="notice">
|
|
119
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
120
|
+
</Banner>
|
|
121
|
+
<Banner sdsType="secondary" intent="notice">
|
|
122
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
123
|
+
</Banner>
|
|
124
|
+
</div>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export default App;
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Banner intents
|
|
132
|
+
|
|
133
|
+
This example shows every intent the Banner supports, each with the icon it picks by default.
|
|
134
|
+
|
|
135
|
+
**Example: BannerIntents**
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
// Every intent, each with the icon the Banner picks by default
|
|
139
|
+
|
|
140
|
+
import { Banner } from "@czi-sds/components";
|
|
141
|
+
|
|
142
|
+
function App() {
|
|
143
|
+
return (
|
|
144
|
+
<div className="app">
|
|
145
|
+
<Banner sdsType="primary" intent="info" dismissible={false}>
|
|
146
|
+
Info: lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
147
|
+
</Banner>
|
|
148
|
+
<Banner sdsType="primary" intent="accent" dismissible={false}>
|
|
149
|
+
Accent: lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
150
|
+
</Banner>
|
|
151
|
+
<Banner sdsType="primary" intent="positive" dismissible={false}>
|
|
152
|
+
Positive: lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
153
|
+
</Banner>
|
|
154
|
+
<Banner sdsType="primary" intent="notice" dismissible={false}>
|
|
155
|
+
Notice: lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
156
|
+
</Banner>
|
|
157
|
+
<Banner sdsType="primary" intent="negative" dismissible={false}>
|
|
158
|
+
Negative: lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
159
|
+
</Banner>
|
|
160
|
+
</div>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export default App;
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Banner with a custom icon
|
|
168
|
+
|
|
169
|
+
This example replaces the icon chosen by the intent with a named SDS icon.
|
|
170
|
+
|
|
171
|
+
**Example: BannerWithACustomIcon**
|
|
172
|
+
|
|
173
|
+
```tsx
|
|
174
|
+
// Replacing the intent's default icon with any SDS icon
|
|
175
|
+
|
|
176
|
+
import { Banner } from "@czi-sds/components";
|
|
177
|
+
|
|
178
|
+
function App() {
|
|
179
|
+
return (
|
|
180
|
+
<div className="app">
|
|
181
|
+
<Banner sdsType="secondary" intent="accent" icon="Bacteria">
|
|
182
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
183
|
+
</Banner>
|
|
184
|
+
</div>
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export default App;
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Banner with a custom background color
|
|
192
|
+
|
|
193
|
+
This example shows how to implement a Banner component with a custom background color.
|
|
194
|
+
|
|
195
|
+
**Example: BannerWithACustomBackgroundColor**
|
|
196
|
+
|
|
197
|
+
```tsx
|
|
198
|
+
import { styled } from "@mui/material/styles";
|
|
199
|
+
import { Banner } from "@czi-sds/components";
|
|
200
|
+
|
|
201
|
+
const StyledBanner = styled(Banner)`
|
|
202
|
+
background-color: Crimson;
|
|
203
|
+
`;
|
|
204
|
+
|
|
205
|
+
function App() {
|
|
206
|
+
return (
|
|
207
|
+
<div className="app">
|
|
208
|
+
<StyledBanner sdsType="primary">
|
|
209
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
210
|
+
</StyledBanner>
|
|
211
|
+
</div>
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export default App;
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Props
|
|
219
|
+
|
|
220
|
+
Any custom SDS props and MUI props required for implementation are found on the table below. See the MUI documentation for additional optional props.
|
|
221
|
+
|
|
222
|
+
| Name | Type | Default | Description |
|
|
223
|
+
| -------------- | -------------------------------------------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
224
|
+
| `sdsType` | `"primary"` \| `"secondary"` | - | Required. The primary variant fills the Banner with the intent's primary surface color and uses the on-fill text color. The secondary variant uses the intent's secondary surface color with the standard primary text color. |
|
|
225
|
+
| `children` | `ReactNode` | - | Required. The content of the Banner, laid out beside the icon and centered in the space left by the close button. |
|
|
226
|
+
| `intent` | `"accent"` \| `"info"` \| `"negative"` \| `"notice"` \| `"positive"` | `"info"` | The intent color of the Banner component, which also selects the default icon. |
|
|
227
|
+
| `dismissible` | `boolean` | `true` | If `true`, the banner can be dismissed by the user. This is what controls whether the close button is rendered. |
|
|
228
|
+
| `dismissed` | `boolean` | - | If `true`, the banner has been dismissed and renders nothing. Leave this unset to let the Banner keep track of its own dismissed state. Passing any value, `false` included, takes that over: the close button then only fires `onClose`, and the Banner closes when you set `dismissed` to `true`. |
|
|
229
|
+
| `onClose` | `function` | - | Callback fired when the user clicks the close button. **Signature:** `function(event: React.MouseEvent) => void` - `event` The event source of the callback. |
|
|
230
|
+
| `icon` | `keyof IconNameToSizes` \| `ReactElement<CustomSVGProps>` | - | The name of an SDS icon, or a custom SVG element, shown in place of the icon the intent would pick. Without it, `"positive"` shows `"CheckCircle"`, `"negative"` and `"notice"` show `"ExclamationMarkCircle"`, and every other intent shows `"InfoCircle"`. |
|
|
231
|
+
| `sdsIconProps` | `Partial<IconProps<keyof IconNameToSizes>>` | - | Additional props to be passed to the icon component. |
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# Button
|
|
2
|
+
|
|
3
|
+
## Source Code
|
|
4
|
+
|
|
5
|
+
The component's source code in the SDS codebase can be found [here](https://github.com/chanzuckerberg/sci-components/blob/main/packages/components/src/core/Button/index.tsx).
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
**React TypeScript**
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { Button } from "@czi-sds/components";
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Code examples
|
|
16
|
+
|
|
17
|
+
### **Default Button**
|
|
18
|
+
|
|
19
|
+
This example has the minimum props needed for the Button component. Without any SDS props it renders as a large, solid, primary button.
|
|
20
|
+
|
|
21
|
+
**Example: DefaultButton**
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { Button } from "@czi-sds/components";
|
|
25
|
+
|
|
26
|
+
function App() {
|
|
27
|
+
return (
|
|
28
|
+
<div className="app">
|
|
29
|
+
<Button>Label</Button>
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default App;
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Button styles
|
|
38
|
+
|
|
39
|
+
This example shows the three styles available through `sdsStyle`, from most to least emphasis.
|
|
40
|
+
|
|
41
|
+
**Example: ButtonStyles**
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import { Button } from "@czi-sds/components";
|
|
45
|
+
|
|
46
|
+
function App() {
|
|
47
|
+
return (
|
|
48
|
+
<div className="app" style={{ display: "flex", gap: "16px" }}>
|
|
49
|
+
<Button sdsStyle="solid">Solid</Button>
|
|
50
|
+
<Button sdsStyle="outline">Outline</Button>
|
|
51
|
+
<Button sdsStyle="minimal">Minimal</Button>
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default App;
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Button types
|
|
60
|
+
|
|
61
|
+
This example shows the three color schemes available through `sdsType`. Each one can be combined with any of the styles above.
|
|
62
|
+
|
|
63
|
+
**Example: ButtonTypes**
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
import { Button } from "@czi-sds/components";
|
|
67
|
+
|
|
68
|
+
function App() {
|
|
69
|
+
return (
|
|
70
|
+
<div className="app" style={{ display: "flex", gap: "16px" }}>
|
|
71
|
+
<Button sdsType="primary">Primary</Button>
|
|
72
|
+
<Button sdsType="secondary">Secondary</Button>
|
|
73
|
+
<Button sdsType="destructive">Destructive</Button>
|
|
74
|
+
</div>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export default App;
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Button sizes
|
|
82
|
+
|
|
83
|
+
This example shows the three sizes available through the `size` prop.
|
|
84
|
+
|
|
85
|
+
**Example: ButtonSizes**
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
import { Button } from "@czi-sds/components";
|
|
89
|
+
|
|
90
|
+
function App() {
|
|
91
|
+
return (
|
|
92
|
+
<div
|
|
93
|
+
className="app"
|
|
94
|
+
style={{ alignItems: "center", display: "flex", gap: "16px" }}
|
|
95
|
+
>
|
|
96
|
+
<Button size="large">Large</Button>
|
|
97
|
+
<Button size="medium">Medium</Button>
|
|
98
|
+
<Button size="small">Small</Button>
|
|
99
|
+
</div>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export default App;
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Button + Icon
|
|
107
|
+
|
|
108
|
+
This example shows a Secondary button component with an icon, placed before the label with `startIcon` and after it with `endIcon`.
|
|
109
|
+
|
|
110
|
+
**Example: ButtonIcon**
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
import { Button, Icon } from "@czi-sds/components";
|
|
114
|
+
|
|
115
|
+
function App() {
|
|
116
|
+
return (
|
|
117
|
+
<div className="app" style={{ display: "flex", gap: "16px" }}>
|
|
118
|
+
<Button
|
|
119
|
+
sdsType="secondary"
|
|
120
|
+
startIcon={<Icon sdsIcon="Download" sdsSize="s" />}
|
|
121
|
+
>
|
|
122
|
+
Download
|
|
123
|
+
</Button>
|
|
124
|
+
<Button
|
|
125
|
+
sdsType="secondary"
|
|
126
|
+
endIcon={<Icon sdsIcon="ChevronRight" sdsSize="s" />}
|
|
127
|
+
>
|
|
128
|
+
Next
|
|
129
|
+
</Button>
|
|
130
|
+
</div>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export default App;
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Icon Button
|
|
138
|
+
|
|
139
|
+
This example shows icon-only buttons, created by passing a single Icon component as the button's child. Each one needs an `aria-label`, since there is no text for screen readers to announce.
|
|
140
|
+
|
|
141
|
+
**Example: IconButton**
|
|
142
|
+
|
|
143
|
+
```tsx
|
|
144
|
+
import { Button, Icon } from "@czi-sds/components";
|
|
145
|
+
|
|
146
|
+
function App() {
|
|
147
|
+
return (
|
|
148
|
+
<div className="app" style={{ display: "flex", gap: "16px" }}>
|
|
149
|
+
<Button aria-label="Download">
|
|
150
|
+
<Icon sdsIcon="Download" sdsSize="s" />
|
|
151
|
+
</Button>
|
|
152
|
+
<Button sdsStyle="outline" sdsType="secondary" aria-label="Copy">
|
|
153
|
+
<Icon sdsIcon="Copy" sdsSize="s" />
|
|
154
|
+
</Button>
|
|
155
|
+
<Button sdsStyle="minimal" sdsType="secondary" aria-label="Delete">
|
|
156
|
+
<Icon sdsIcon="TrashCan" sdsSize="s" />
|
|
157
|
+
</Button>
|
|
158
|
+
</div>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export default App;
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## SDS vs MUI
|
|
166
|
+
|
|
167
|
+
The following props are available to MUI's Button component, but produce no effect (or unexpected effects) for SDS's Button component, so **it is recommended to not use them**:
|
|
168
|
+
|
|
169
|
+
- `variant`: This prop is intended to set the Button to either text only, contained, or outlined. With SDS's Button, they do not function as described in the MUI documentation; however, similar effects, specific to SDS's styles, can be achieved through a combination of the SDS-only props: `sdsStyle` and `sdsType` (see details below).
|
|
170
|
+
|
|
171
|
+
- `color`: SDS's Button does not support the colors or intents that would be expected through this prop. However, the `sdsType` prop can be used to set the button color as `"primary"`, `"secondary"`, or `"destructive"`.
|
|
172
|
+
|
|
173
|
+
- `disableElevation`: The SDS Button component doesn't have a visual "elevation" or shadowed treatment by default (which this prop disables for MUI's Button). Setting `disableElevation={false}` will not render the MUI default elevation treatment.
|
|
174
|
+
|
|
175
|
+
Icons can be used in both MUI and SDS Button component, but are called in slightly different ways:
|
|
176
|
+
|
|
177
|
+
- `startIcon` and `endIcon`: Both of these props are supported by both MUI and SDS's Buttons. However, MUI expects the prop to receive an individual icon as its own component (for example `startIcon={<DeleteIcon />}`), whereas SDS takes the Icon component which references which specific icon to call, as one of its props, as such:
|
|
178
|
+
|
|
179
|
+
**React TypeScript**
|
|
180
|
+
|
|
181
|
+
```tsx
|
|
182
|
+
startIcon={<Icon sdsIcon="Download" sdsSize="s" />}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
To render an icon-only button, pass a single Icon component as the button's child instead of using `startIcon` or `endIcon`. The Button detects the icon-only child and adjusts its padding to stay square. Remember to give the button an `aria-label`, since it has no text for screen readers to announce:
|
|
186
|
+
|
|
187
|
+
**React TypeScript**
|
|
188
|
+
|
|
189
|
+
```tsx
|
|
190
|
+
<Button aria-label="Download">
|
|
191
|
+
<Icon sdsIcon="Download" sdsSize="s" />
|
|
192
|
+
</Button>
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
SDS's Button has additional props to allow flexibility while maintaining the SDS styles:
|
|
196
|
+
|
|
197
|
+
- `sdsStyle`: takes `"solid"` (default, filled), `"outline"`, or `"minimal"` as values
|
|
198
|
+
|
|
199
|
+
- `sdsType`: takes `"primary"` (default), `"secondary"`, or `"destructive"` as values, and sets the color scheme within the chosen style
|
|
200
|
+
|
|
201
|
+
- `size`: MUI's `size` prop is supported and takes `"small"`, `"medium"`, or `"large"` (default), driving the button's height, padding, type ramp, and icon size
|
|
202
|
+
|
|
203
|
+
## MUI Documentation
|
|
204
|
+
|
|
205
|
+
Documentation for the underlying MUI Button component can be found [here](https://mui.com/material-ui/react-button/).
|
|
206
|
+
|
|
207
|
+
## Props
|
|
208
|
+
|
|
209
|
+
Any custom SDS props and MUI props required for implementation are found on the tables below. See the MUI documentation for additional optional props.
|
|
210
|
+
|
|
211
|
+
| Name | Type | Default | Description |
|
|
212
|
+
| ---------------------- | ----------------------------------------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
213
|
+
| `sdsStyle` | `"solid"` \| `"outline"` \| `"minimal"` | `"solid"` | Style of the button, in descending order of emphasis. Solid is filled, outline draws a 1px border over a transparent background, and minimal is text only. |
|
|
214
|
+
| `sdsType` | `"primary"` \| `"secondary"` \| `"destructive"` | `"primary"` | Color scheme of the button within the chosen style. Primary uses the accent color, secondary is neutral, and destructive signals an irreversible action. |
|
|
215
|
+
| `size` | `"small"` \| `"medium"` \| `"large"` | `"large"` | Size of the button. Drives the height, padding, type ramp, and icon size, each of which also adapts at the `md` breakpoint. |
|
|
216
|
+
| `backgroundOnHover` | `boolean` | `true` | Only applies when `sdsStyle` is `"minimal"`. When `false`, the button drops its padding and renders no background on hover or press, so it sits flush with surrounding text. |
|
|
217
|
+
| `backgroundAppearance` | `"matchBackground" \| "dark"` | `"matchBackground"` | Tells the button which surface it sits on so it can pick colors with enough contrast. Set it to `"dark"` when the button is placed on a dark background in light mode. |
|
|
218
|
+
| `startIcon` | `ReactNode` | - | An icon placed before the label. Pass the SDS Icon component, for example `<Icon sdsIcon="Download" sdsSize="s" />`. |
|
|
219
|
+
| `endIcon` | `ReactNode` | - | An icon placed after the label. |
|
|
220
|
+
| `children` | `ReactNode` | - | The button label. Passing a single Icon component as the only child renders an icon-only button, which the component detects and pads symmetrically. |
|
|
221
|
+
| `disabled` | `boolean` | `false` | Disables the button when set to `true`. |
|
|
222
|
+
| `onClick` | `(event: React.MouseEvent) => void` | - | Callback fired when the button is clicked. |
|
|
223
|
+
| `href` | `string` | - | Renders the button as an anchor pointing at the given URL. Pair it with `target` to control where the link opens. |
|
|
224
|
+
| `target` | `string` | - | Where the link opens, for example `"_blank"`. Only has an effect alongside `href`. |
|