Getting Started
Components
- Advanced Toast
- ArrowButton
- Arrows
- Avatar
- Backdrop
- Basic Toast
- Breadcrumb
- Button
- CardBackground
- Card
- ChatButton
- Checkbox
- Checkboxes
- Chip
- ChoiceExpander
- Clickable
- Date Field
- Dropdown
- ElasticHeight
- ExpandableCard
- Filter
- FormCheckbox
- Form Control
- Form Label
- HamburgerIcon
- Heading
- Image
- Link
- Loader
- Number Field
- Pagination
- Password
- Phone Field
- Popin
- Portal
- Prose
- Radio Group
- Radio
- Range
- Select
- SidebarLayout
- Spinner
- Switch
- Tabs
- Tag
- TextField
- ValidationMessage
Welcome to Trident UI
'use client';
import { Heading } from '@/ui/heading/Heading';
export function HeadingDemo() {
return (
<Heading level={2} className="text-2xl font-bold">
Welcome to Trident UI
</Heading>
);
}
Installation
npx shadcn@latest add https://develop.trident-ui.pro.clubmed/r/heading.json
Usage
import Heading from '@/docs/lib/ui/heading';
export function Component() {
return (
<div className="space-y-4">
<Heading level={1} className="text-4xl font-bold">
Main Title
</Heading>
<Heading level={2} className="text-2xl font-semibold">
Section Heading
</Heading>
<Heading level={3} className="text-xl">
Subsection
</Heading>
</div>
);
}API Reference
Heading
| Prop | Type | Default | Description |
|---|---|---|---|
level | 1 | 2 | 3 | 4 | 5 | 6 | 2 | The heading level to render (h1-h6). The level is automatically clamped between 1 and 6 if an invalid value is provided. |
asDiv | boolean | false | When true, renders a <div> element instead of a heading tag, but maintains semantic heading behavior with proper ARIA attributes (role="heading" and aria-level). Useful for styling flexibility when the semantic heading level doesn't match the visual hierarchy. |
children | React.ReactNode | - | The content to display inside the heading. |
className | string | - | Additional CSS classes to apply to the heading element. |
The component also accepts all standard HTML attributes for h1-h6 elements (or div when asDiv={true}).
Notes
- Semantic HTML: By default, the component renders the appropriate semantic heading element (h1-h6) based on the
levelprop, which is important for accessibility and SEO. - Level Clamping: The
levelprop is automatically clamped between 1 and 6 to ensure valid HTML output. - Accessibility with asDiv: When
asDiv={true}, the component automatically addsrole="heading"andaria-levelattributes to maintain proper semantics for screen readers. - Styling Flexibility: Use the
asDivprop when you need to style a heading differently from its semantic level. For example, you might need an h4 semantically but want it to look like an h2 visually. - No Default Styling: The component provides no built-in styles, allowing complete control over the appearance through className or global styles.