Getting Started
Components
- Accordion
- Advanced Toast
- AlertMessage
- ArrowButton
- Arrows
- Avatar
- Backdrop
- Basic Toast
- Breadcrumb
- Button
- CardBackground
- Card
- Carousel
- Chapters
- ChatBody
- ChatButton
- ChatHeader
- ChatInput
- ChatMessageActions
- ChatMessageEditor
- ChatMessage
- ChatTypingIndicator
- ChatWindowCsatPrompt
- ChatWindowQuote
- ChatWindow
- CheckboxSelect
- Checkbox
- Checkboxes
- Chip
- ChoiceExpander
- Clickable
- ContentReview
- Countdown
- CriteriaDates
- CriteriaParticipants
- CriteriaTransports
- Date Field
- Datepicker
- Dropdown
- ElasticHeight
- ExpandableCard
- ExpandableText
- Filter
- FloatingLabelTextField
- Form Control
- Form Label
- Frame
- HamburgerIcon
- Heading
- Image
- JourneyCard
- LayerHeader
- Layer
- Link
- Loader
- Number Field
- PageNavigation
- Pagination
- Paragraph
- Password
- Phone Field
- Popin
- Portal
- ProductThumbnail
- Promises
- Prose
- Radio Group
- RadioSelect
- Radio
- Range
- Scrollbar
- Select
- SidebarLayout
- SliderFrame
- SparkleWrapper
- Spinner
- Switch
- Table
- Tabs
- Tag
- TextField
- Toggle
- Tooltip
- ValidationMessage
Click me or press Enter/Space
'use client';
import { Clickable } from '@/ui/Clickable';
export function ClickableDemo() {
return (
<Clickable
onClick={() => alert('Clicked!')}
className="rounded-lg border-2 border-dashed border-gray-300 p-6 text-center hover:border-gray-400 hover:bg-gray-50"
>
Click me or press Enter/Space
</Clickable>
);
}
Installation
npx shadcn@latest add https://develop.trident-ui.pro.clubmed/r/clickable.json
Usage
import { Clickable } from '@/docs/lib/ui/clickable';
export function Component() {
const handleClick = () => {
console.log('Clicked!');
};
return (
<Clickable onClick={handleClick} className="rounded-lg p-4 hover:bg-gray-100">
Click me or press Enter/Space
</Clickable>
);
}API Reference
Clickable
| Prop | Type | Default | Description |
|---|---|---|---|
onClick | () => void | undefined | Required. Callback function to execute when the element is clicked or activated via keyboard. |
children | ReactNode | undefined | The content to render inside the clickable area. |
className | string | undefined | Additional CSS classes to apply to the clickable div. |
The component also accepts all standard HTML div element attributes via ComponentPropsWithoutRef<"div">.
Notes
- Accessibility: The component automatically sets
role="button"andtabIndex={0}to make the div keyboard accessible and screen-reader friendly. - Keyboard Support: Responds to both
EnterandSpacekeys, matching native button behavior. - Click Handler: The
onClickcallback is triggered by mouse clicks, touch events, and keyboard activation (Enter/Space keys). - Forwarded Ref: Supports React ref forwarding, allowing parent components to access the underlying div element.
- Use Case: Ideal for making custom clickable areas, cards, or complex interactive elements that aren't semantic buttons but need button-like behavior.
- Semantic HTML: When possible, prefer using semantic
<button>elements. Use Clickable when you need clickable behavior on a container with complex children or layout requirements that are difficult to achieve with a button element.