-
Notifications
You must be signed in to change notification settings - Fork 616
Update component docs (Header, Radio, Checkbox, Heading, Label, LabelGroup) #1708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f356d91
b9ccc23
f27b94a
84bf8e7
04bbdf4
68e5ba0
58b8840
e130ede
6c06832
dcc990d
8161211
5364786
1098cb1
5e4c0e4
d32dc87
2345eb6
ff10c7c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,24 @@ | ||
--- | ||
componentId: checkbox | ||
title: Checkbox | ||
description: Use checkboxes to toggle between checked and unchecked states in a list or as a standalone form field | ||
status: Alpha | ||
source: https://github.com/primer/react/blob/main/src/Checkbox.tsx | ||
storybook: '/react/storybook?path=/story/forms-checkbox--default' | ||
componentId: checkbox | ||
--- | ||
|
||
import {ComponentChecklist} from '../src/component-checklist' | ||
|
||
## Examples | ||
|
||
<Note variant="warning"> | ||
|
||
**Use [ChoiceInputField](/ChoiceInputField) to display an accessible checkbox form field**. This `Checkbox` component is intended only as an ingredient for other custom components, or as a drop-in replacement for native HTML checkboxes outside of form use-cases. | ||
|
||
|
||
If you do use this component to build a custom checkbox, it should always be accompanied by a corresponding `<label>` to improve support for assistive technologies. | ||
|
||
</Note> | ||
|
||
## Default example | ||
|
||
The `Checkbox` component can be used in controlled and uncontrolled modes. | ||
|
||
```jsx live | ||
|
@@ -53,10 +52,11 @@ The `Checkbox` component can be used in controlled and uncontrolled modes. | |
``` | ||
|
||
<Note variant="warning"> | ||
Checkbox components should always be accompanied by a corresponding label to improve support for assistive technologies. | ||
Checkbox components should always be accompanied by a corresponding label to improve support for assistive | ||
technologies. | ||
</Note> | ||
|
||
## Indeterminate example | ||
## Indeterminate | ||
|
||
An `indeterminate` checkbox state should be used if the input value is neither true nor false. This can be useful in situations where you are required to display an incomplete state, or one that is dependent on other input selections to determine a value. | ||
|
||
|
@@ -95,22 +95,59 @@ An `indeterminate` checkbox state should be used if the input value is neither t | |
</> | ||
``` | ||
|
||
## Component props | ||
|
||
Native `<input>` attributes are forwarded to the underlying React `input` component and are not listed below. | ||
|
||
| Name | Type | Default | Description | | ||
| :------------- | :---------- | :-------: | :------------------------------------------------------------------------------------------------------------------------------------------------------ | | ||
| checked | Boolean | undefined | Optional. Modifies true/false value of the native checkbox | | ||
| defaultChecked | Boolean | undefined | Optional. Checks the input by default in uncontrolled mode | | ||
| onChange | ChangeEvent | undefined | Optional. A callback function that is triggered when the checked state has been changed. | | ||
| disabled | Boolean | undefined | Optional. Modifies the native disabled state of the native checkbox | | ||
| indeterminate | Boolean | undefined | Optional. Applies an [indeterminate](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#attr-indeterminate) state to the checkbox | | ||
|
||
## Component status | ||
## Props | ||
|
||
<PropsTable> | ||
<PropsTableRow | ||
name="checked" | ||
type="boolean" | ||
description="Modifies true/false value of the native checkbox" | ||
/> | ||
<PropsTableRow | ||
name="defaultChecked" | ||
type="boolean" | ||
description="Checks the input by default in uncontrolled mode" | ||
/> | ||
<PropsTableRow | ||
name="onChange" | ||
type="(event: React.ChangeEvent) => void" | ||
description="A callback function that is triggered when the checked state has been changed" | ||
/> | ||
<PropsTableRow | ||
name="disabled" | ||
type="boolean" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this have a default value? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's an optional prop, so no. Or are you setting undefined explicitly? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to say this defaults to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that's misrepresenting the data type, as false !== undefined. I think literally |
||
description="Modifies the native disabled state of the native checkbox" | ||
/> | ||
<PropsTableRow | ||
name="indeterminate" | ||
type="boolean" | ||
rezrah marked this conversation as resolved.
Show resolved
Hide resolved
|
||
defaultValue="false" | ||
description={ | ||
<> | ||
Applies an{' '} | ||
<Link href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#attr-indeterminate"> | ||
indeterminate state | ||
</Link>{' '} | ||
to the checkbox | ||
</> | ||
} | ||
/> | ||
<PropsTableBasePropRows | ||
elementType="input" | ||
refType="HTMLInputElement" | ||
passthroughPropsLink={ | ||
<Link href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#additional_attributes"> | ||
MDN | ||
</Link> | ||
} | ||
/> | ||
|
||
</PropsTable> | ||
|
||
## Status | ||
|
||
<ComponentChecklist | ||
items={{ | ||
items={{ | ||
propsDocumented: true, | ||
noUnnecessaryDeps: true, | ||
adaptsToThemes: true, | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
title: Heading | ||
description: Use Heading to structure your content and provide an accessible experience for users of assistive technologies. | ||
source: https://github.com/primer/react/blob/main/src/Heading.tsx | ||
status: Alpha | ||
rezrah marked this conversation as resolved.
Show resolved
Hide resolved
|
||
componentId: heading | ||
--- | ||
|
||
The Heading component will render an html `h2` tag without any default styling. Other heading level elements `h1-h6` are available through use of the `as` prop (see [System Props](/system-props) for additional explanation). Please reference the [w3 recommendations for headings](https://www.w3.org/WAI/tutorials/page-structure/headings/) to ensure your headings provide an accessible experience for screen reader users. | ||
|
||
**Attention:** Make sure to include a valid heading element to render a Heading component other than `h2` (`<Heading as="h1">H1 Element</Heading>`). | ||
|
||
## Example | ||
|
||
```jsx live | ||
<Heading sx={{fontSize: 1, mb: 2}}>H2 heading with fontSize={1}</Heading> | ||
``` | ||
|
||
## Props | ||
|
||
<PropsTable> | ||
<PropsTableAsRow defaultElementType="h2" /> | ||
<PropsTableSxRow /> | ||
</PropsTable> | ||
colebemis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Status | ||
|
||
<ComponentChecklist | ||
items={{ | ||
propsDocumented: true, | ||
noUnnecessaryDeps: true, | ||
adaptsToThemes: true, | ||
adaptsToScreenSizes: false, | ||
fullTestCoverage: true, | ||
usedInProduction: false, | ||
usageExamplesDocumented: true, | ||
designReviewed: false, | ||
a11yReviewed: false, | ||
stableApi: false, | ||
addressedApiFeedback: false, | ||
hasDesignGuidelines: false, | ||
hasFigmaComponent: false | ||
}} | ||
/> |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The heading of prop tables is usually the name of the component:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example heading in the Issue description here shows it as Props, which feels sensible given the content it describes... or am I misunderstanding this? What was the reasoning behind repeating the component name here?