Repository navigation
docs(label): add label component page #2228
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import Documentation from "@/components/layout/Documentation/Documentation" | ||
| import LabelExample from "./docs/examples/LabelExample" | ||
| import codeUsage, { api_documentation, features } from "./docs/codeUsage" | ||
|
|
||
| <Documentation | ||
| title="Label" | ||
| description="Label renders a native label that names a form control. Use it with htmlFor, or wrap the control, so screen readers announce the control's name and clicking the label focuses it." | ||
| > | ||
| <Documentation.ComponentHero codeUsage={codeUsage}> | ||
| <LabelExample /> | ||
| </Documentation.ComponentHero> | ||
|
|
||
| <Documentation.ComponentFeatures features={features} /> | ||
|
|
||
| <Documentation.Section title="API Documentation" as="h2"> | ||
| <Documentation.Table | ||
| title="Label" | ||
| description={api_documentation.label.description} | ||
| columns={api_documentation.label.columns} | ||
| data={api_documentation.label.data} | ||
| /> | ||
| </Documentation.Section> | ||
| </Documentation> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { getSourceCodeFromPath } from '@/utils/parseSourceCode'; | ||
|
|
||
| import label_api_SourceCode from './component_api/label.tsx'; | ||
|
|
||
| const example_SourceCode = await getSourceCodeFromPath('docs/app/docs/components/label/docs/examples/LabelExample.tsx'); | ||
| const scss_SourceCode = await getSourceCodeFromPath('src/components/ui/Label/label.clarity.scss'); | ||
|
|
||
| const code = { | ||
| javascript: { | ||
| code: example_SourceCode | ||
| }, | ||
| scss: { | ||
| code: scss_SourceCode | ||
| } | ||
| }; | ||
|
|
||
| export const api_documentation = { | ||
| label: label_api_SourceCode | ||
| }; | ||
|
|
||
| export const features = [ | ||
| "Native <label>, so clicking it focuses or toggles the control it names", | ||
| "Name a control with htmlFor, or by wrapping the control", | ||
| "Double-clicking the label doesn't select its text; nested controls still get their own clicks", | ||
| "asChild to render your own element with the label's props", | ||
| "Unstyled by default, with Clarity and baremetal styles available" | ||
| ]; | ||
|
|
||
| export default code; |
17 changes: 17 additions & 0 deletions
17
docs/app/docs/components/label/docs/component_api/label.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| const data = { | ||
| name: "Label", | ||
| description: "Renders a native <label> that names a form control, either through htmlFor or by wrapping the control.", | ||
| columns: [ | ||
| { name: "Prop", id: "prop" }, | ||
| { name: "Type", id: "type" }, | ||
| { name: "Default", id: "default" } | ||
| ], | ||
| data: [ | ||
| { prop: { name: "htmlFor", info_tooltips: "The id of the form control this label names." }, type: "string", default: "--" }, | ||
| { prop: { name: "asChild", info_tooltips: "Render the child element instead of a <label>, merging the label's props onto it." }, type: "boolean", default: "false" }, | ||
| { prop: { name: "customRootClass", info_tooltips: "Class namespace for the root class (e.g. \"acme\" gives acme-label)." }, type: "string", default: "''" }, | ||
| { prop: { name: "className", info_tooltips: "Additional CSS class names." }, type: "string", default: "''" } | ||
| ] | ||
| }; | ||
|
|
||
| export default data; |
17 changes: 17 additions & 0 deletions
17
docs/app/docs/components/label/docs/examples/LabelExample.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| 'use client' | ||
|
|
||
| import Label from "@radui/ui/Label" | ||
|
|
||
| const LabelExample = () => ( | ||
| <div className="flex w-64 flex-col gap-2"> | ||
| <Label htmlFor="label-example-email">Email address</Label> | ||
| <input | ||
| id="label-example-email" | ||
| type="email" | ||
| placeholder="you@example.com" | ||
| className="rounded-md border border-gray-400 bg-gray-50 px-3 py-2 text-sm text-gray-1000" | ||
| /> | ||
| </div> | ||
| ) | ||
|
|
||
| export default LabelExample | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { createDocsPage } from '@/components/docsPage/createDocsPage' | ||
| import metadata from './seo' | ||
| import Content from './content.mdx' | ||
|
|
||
| export { metadata } | ||
|
|
||
| export default createDocsPage(Content) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import generateSeoMetadata from "@/utils/seo/generateSeoMetadata" | ||
|
|
||
| const metadata = generateSeoMetadata({ | ||
| title: "Label - Rad UI", | ||
| description: "Accessible, headless React Label component. Names form controls with a native label, supports asChild, and avoids text selection on double-click.", | ||
| keywords: ["React Label", "headless label", "accessible label", "form label component", "React label component"], | ||
| canonicalUrl: "https://www.rad-ui.com/docs/components/label" | ||
| }); | ||
|
|
||
| export default metadata |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.