Button
buttonuiInteractive button component with variants (default, destructive, outline, secondary, ghost, link), sizes, and composite ButtonGroup container for segmented toolbars and split buttons.
Installation
$pnpm dlx shadcn@latest add https://uipkge.dev/r/react/button.json$npx shadcn@latest add https://uipkge.dev/r/react/button.json$yarn dlx shadcn@latest add https://uipkge.dev/r/react/button.json$bunx shadcn@latest add https://uipkge.dev/r/react/button.jsonNamed registry:
npx shadcn@latest add @uipkge-react/buttonInstalls to:components/ui/button/Examples
Loading interactive previews…
Loading interactive previews…
Props
| Name | Type / Values | Default | Required |
|---|---|---|---|
variant | 'default''destructive''outline''secondary''ghost''link' | default | optional |
size | 'default''sm''lg''xs''icon''icon-sm''icon-lg' | default | optional |
asChildemitting a <button> — the React equivalent of reka-ui's as-child. Use it to give a Next.js <Link> or <a> full button styling. | boolean | false | optional |
npm dependencies
Used by
ab-test-variant-resultsaccess-request-workflowad-spend-roi-dashboardagent-memory-inspectorai-agent-orchestratorai-code-review-assistantai-crm-pipeline-dashboardai-llm-chatai-saas-command-centerairbnb-host-earningsalert-modalannouncementannouncement-banner-splitannouncement-corner-toastannouncement-countdown-barannouncement-rotating-stripapi-documentation-pageapi-keysarticle-editor-toolbarasset-tracking-mapassignment-submission-dropzoneaudio-waveform-transcriptaudit-event-streamaudit-logauth-mfaauth-password-resetauth-sign-inauth-sign-upauthor-bio-boxbackorder-split-shipment-managerbank-account-connectorbefore-after-side-by-sidebefore-after-togglebenefits-enrollment-portalbento-01bento-asymmetric-gridbento-metrics-mixedbill-of-lading-viewerbilling-accountbilling-usage-centerblog-post-card-gridboard-resolution-signoffbookmark-manager-gridcalendarcap-table-ownership-summarycareers-job-boardcarouselcart-drawercase-studycase-study-featured-storycase-study-filterable-listcase-study-metric-cardscase-study-metric-comparisoncase-study-results-stripcash-flow-treasury-dashboardcategory-showcasecdc-replication-streamcertificate-credential-cardchangelogchat-threadchat-two-panecheckout-flowcloud-backup-schedulecode-blockcode-diff-reviewcode-install-commandcode-snippet-playgroundcode-tabs-multi-languagecode-terminal-sessioncold-chain-temp-monitorcolumn-profiling-summarycoming-sooncommercial-invoice-generatorcommute-reimbursement-claimscomparison-migration-pathcomparison-tablecomparison-vs-alternativescompensation-band-benchmarkingcompliance-sanctions-screenercompliance-soc2-readinesscontact-01contact-uscontent-calendar-matrixcontract-redline-diffcontractor-timesheet-approvalcookie-consentcookie-consent-bannercookie-consent-barcookie-consent-preferencescourse-curriculum-outlinecrm-sales-call-workbenchcron-job-schedulercrypto-wallet-portfoliocta-01cta-final-bandcta-gradient-glow-actioncta-split-demo-request-modalcta-split-panelcurrency-converter-widgetcustomer-journey-mapcustomer-reviewscustoms-clearance-trackerdaily-standup-summarydashboard-layoutdata-catalog-lineagedata-contract-governancedata-explorerdata-mesh-domain-catalogdata-product-carddata-quality-metricsdata-retention-policy-managerdata-tabledata-table-pagedatabase-migration-schema-diffdatabase-schema-viewerdate-pickerdbt-model-graphdecision-matrix-tabledefi-staking-yield-vaultdelivery-proof-carddelivery-tracking-mapdemo-guided-tourdemo-sandbox-paneldeployment-pipelinedialogdisaster-response-mapdispatch-assignment-boarddns-record-managerdoctor-appointment-schedulerdriver-inspection-checklistemail-campaign-composeremail-template-previeweremployee-org-chart-treeemployee-pulse-survey-resultsempty-statesenterprise-workspace-switcherenvironment-variables-managererror-404error-500error-pageerror-pagesetl-pipeline-dagevent-calendarevent-calendar-dashboardexit-intentexit-intent-newsletterexit-intent-offerexit-intent-surveyexit-interview-surveyfaq-01faq-categorized-tabsfaq-contact-sidebarfaq-searchable-accordion-workbenchfaq-two-columnfeature-accordion-mediafeature-alternating-rowsfeature-bento-ai-copilotfeature-code-preview-splitfeature-comparison-sliderfeature-drag-drop-organizerfeature-flags-managerfeature-full-bleed-rowsfeature-hover-tilt-cardsfeature-interactive-api-curl-builderfeature-metric-growth-stepperfeature-segmented-comparefeature-sticky-media-scrollfeature-store-registryfeature-tabbed-deepdivefeature-vertical-tabs-panefeatures-01features-2x2-spotlightfeatures-checklist-splitfeatures-icon-list-densefeatures-numbered-gridfield-inspection-managerfile-managerfine-tuning-job-monitorflash-sale-offer-barflashcard-study-deckflight-radar-mapfloor-plan-explorerfooterfooter-01footer-brand-statementfooter-developer-dense-gridfooter-mega-newsletterfooter-minimal-rowfooter-sitemap-denseform-layoutsfreelance-work-for-hire-contractfreight-quote-calculatorfrequently-bought-togetherganttgift-card-balance-checkergithub-oss-traction-bandgraphql-query-explorerguardrails-safety-scannerhabit-streak-trackerheaderheader-01header-announcement-stackheader-centered-logoheader-floating-pillheader-mega-menuheader-search-commandheader-transparent-scrollherohero-01hero-3d-tilt-interactive-canvashero-ascii-terminal-streamhero-bento-preview-gridhero-developer-terminalhero-globe-interactive-nodeshero-saas-metrics-dashboardhero-split-device-mockuphero-video-modal-walkthroughhero-waitlist-glowhotel-booking-reservationhow-it-works-arrow-flowhow-it-works-before-afterhow-it-works-scroll-stepperhow-it-works-stepshow-it-works-tabbed-stepshow-it-works-timelineimmunization-historyimport-wizardinboxinfluencer-campaign-cardinsurance-eligibility-checkerintegrations-connector-statusintegrations-directoryintegrations-featured-pairsintegrations-hub-diagramintegrations-logo-gridintegrations-search-directoryinventory-reorder-forecastinvite-membersinvoice-creator-wizardinvoices-listkafka-stream-monitorkanban-task-boardknowledge-base-hublab-results-viewerlakehouse-table-optimizerlast-mile-courier-dispatchlead-capture-popupleaflet-asset-tracking-mapleaflet-delivery-tracking-mapleaflet-disaster-response-mapleaflet-flight-radar-mapleaflet-last-mile-courier-dispatchleaflet-maritime-vessel-mapleaflet-neighborhood-walkscore-cardleaflet-property-boundary-maplease-agreement-signlegal-policy-pagelesson-video-playerllm-eval-benchmark-matrixloan-calculatorlogin-01login-02logo-cloud-grayscalelogosloyalty-rewards-tier-hubmaintenance-request-ticketmaritime-vessel-mapmatrix-swot-analysismcp-server-registry-managermedia-asset-gallerymeeting-agenda-notesmodel-token-cost-optimizermultimodal-vision-playgroundnda-agreement-generatorneighborhood-walkscore-cardnewsletternewsletter-inline-bandnewsletter-issue-archivenewsletter-signupnewsletter-split-previewnotification-centernotifications-popoveronboarding-checklistonboarding-equipment-provisioningonboarding-wizardorder-confirmationorder-management-pagepacking-slip-generatorparquet-metadata-inspectorpassword-generator-widgetpatient-intake-formpatient-medical-recordpayment-formpayouts-management-tablepayroll-run-summarypeer-discussion-forumperformance-review-matrixpersonal-finance-budgetpodcast-audio-playerpomodoro-focus-timerprescription-refill-managerpress-kit-brand-assetsprice-drop-alert-cardpricingpricing-01pricing-calculatorpricing-enterprise-sla-cardpricing-feature-addon-builderpricing-feature-tier-sliderpricing-matrix-groupedpricing-matrix-plan-cardspricing-matrix-sticky-headerpricing-single-planpricing-tier-comparison-matrixpricing-usage-calculator-sliderprivacy-data-export-portalprivacy-policy-generatorproduct-comparison-drawerproduct-detail-pageproduct-grid-pageproduct-qa-communityproject-roadmapprompt-ab-testing-comparatorprompt-playgroundproperty-amenities-gridproperty-boundary-mapproperty-listing-cardpurchase-order-receivingquiz-assessment-runnerrag-pipeline-visualizerrange-calendarrate-limiting-configratings-award-wallratings-review-badgesratings-star-summaryrecord-detail-pagerecruitment-candidate-pipelinereferral-program-widgetregister-01resources-category-gridresources-featured-listresources-teaser-gridreturn-merchandise-inspectionreturns-portalreverse-etl-sync-managerrich-text-editorroi-calculator-inputssafe-note-calculatorsaved-cards-listschema-drift-alert-boardsearch-results-pagesecrets-rotation-schedulersecurity-certification-bandsecurity-compliance-badgessecurity-data-flowsecurity-incident-timelinesecurity-trust-center-gridseo-audit-checklistservice-health-matrixsession-device-managersettings-pageshipment-tracking-timelineshipping-label-printershortcuts-dialogsidebarskill-assessment-radarsmart-inbox-triagesocial-media-post-schedulerspark-job-stage-visualizersql-query-notebooksso-identity-provider-configstats-bandsticky-ctasticky-cta-barsticky-cta-corner-buttonsticky-cta-reading-progressstock-transfer-managerstore-pickup-curbsidestream-processing-flink-topologystudent-gradebook-tablesubpoena-legal-hold-managersubscription-churn-analyticssupport-ticket-detailsynthetic-data-generatortax-summary-reportteam-sectiontechnical-specs-sheettelehealth-video-roomtenant-rent-ledgertestimonialtestimonial-quote-carousel-telemetrytestimonial-single-featuredtestimonial-social-cardstestimonials-01theme-customizetime-off-portaltime-pickertime-tracker-timesheettourtrademark-patent-portfoliotraining-compliance-trackertransaction-feedtransfertriage-queue-dashboardusage-metering-dashboarduse-casesuse-cases-industry-griduse-cases-persona-tabsuse-cases-role-cardsuse-cases-scenario-walkthroughuser-profile-pageutm-campaign-buildervector-embeddings-inspectorvendor-supplier-portalvideo-playlist-sidebarvirtual-card-managervirtual-tour-panoramavitals-tracker-chartvulnerability-scanner-reportwaitlistwaitlist-referral-positionwarehouse-inventory-gridwave-picking-consolewebhook-testerwebhookswholesale-b2b-quick-order
Files installed (4)
components/ui/button/Button.tsx1.2 kB
import * as React from 'react' import { Slot } from '@radix-ui/react-slot' import { cn } from '@/lib/utils' import { buttonVariants, type ButtonVariants } from './button.variants' export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, ButtonVariants { /** Render the child element as the button (merging props/styles) instead of * emitting a <button> — the React equivalent of reka-ui's as-child. Use it * to give a Next.js <Link> or <a> full button styling. */ asChild?: boolean } const Button = React.forwardRef<HTMLButtonElement, ButtonProps>( ({ className, variant = 'default', size = 'default', asChild = false, type = 'button', ...props }, ref) => { const Comp = asChild ? Slot : 'button' return ( <Comp data-uipkge="" data-slot="button" data-variant={variant} data-size={size} className={cn(buttonVariants({ variant, size }), className)} // Default type="button" avoids accidental form submits. asChild leaves // type to the child (e.g. <a> / Next.js Link) and must not receive it. {...(asChild ? {} : { type })} ref={ref} {...props} /> ) }, ) Button.displayName = 'Button' export { Button }components/ui/button/ButtonGroup.tsx3.6 kB
'use client' import * as React from 'react' import { cn } from '@/lib/utils' export interface ButtonGroupProps extends React.HTMLAttributes<HTMLDivElement> { orientation?: 'horizontal' | 'vertical' attached?: boolean } export const ButtonGroup = React.forwardRef<HTMLDivElement, ButtonGroupProps>( ({ className, orientation = 'horizontal', attached = true, children, ...props }, ref) => { return ( <div ref={ref} role="group" data-uipkge="" data-slot="button-group" data-orientation={orientation} data-attached={attached ? '' : undefined} className={cn( 'inline-flex items-center', orientation === 'vertical' ? 'flex-col items-stretch' : 'flex-row', attached && [ '[&>[data-slot=button]]:relative [&>[data-slot=button]:focus-visible]:z-20 [&>[data-slot=button]:hover]:z-10', '[&>button]:relative [&>button:focus-visible]:z-20 [&>button:hover]:z-10', orientation === 'horizontal' && [ '[&>[data-slot=button]]:rounded-none [&>button]:rounded-none', '[&>[data-slot=button]:first-child]:rounded-l-md [&>button:first-child]:rounded-l-md', '[&>[data-slot=button]:last-child]:rounded-r-md [&>button:last-child]:rounded-r-md', '[&>[data-slot=button]:only-child]:rounded-md [&>button:only-child]:rounded-md', '[&>[data-slot=button]:not(:first-child)]:-ml-px [&>button:not(:first-child)]:-ml-px', '[&>[data-slot=button][data-variant=default]:not(:first-child)]:border-primary-foreground/20 [&>[data-slot=button][data-variant=default]:not(:first-child)]:border-l', '[&>[data-slot=button]:not([data-variant]):not(:first-child)]:border-primary-foreground/20 [&>[data-slot=button]:not([data-variant]):not(:first-child)]:border-l', '[&>[data-slot=button][data-variant=secondary]:not(:first-child)]:border-border [&>[data-slot=button][data-variant=secondary]:not(:first-child)]:border-l', '[&>[data-slot=button][data-variant=destructive]:not(:first-child)]:border-l [&>[data-slot=button][data-variant=destructive]:not(:first-child)]:border-white/20', ], orientation === 'vertical' && [ '[&>[data-slot=button]]:rounded-none [&>button]:rounded-none', '[&>[data-slot=button]:first-child]:rounded-t-md [&>button:first-child]:rounded-t-md', '[&>[data-slot=button]:last-child]:rounded-b-md [&>button:last-child]:rounded-b-md', '[&>[data-slot=button]:only-child]:rounded-md [&>button:only-child]:rounded-md', '[&>[data-slot=button]:not(:first-child)]:-mt-px [&>button:not(:first-child)]:-mt-px', '[&>[data-slot=button][data-variant=default]:not(:first-child)]:border-primary-foreground/20 [&>[data-slot=button][data-variant=default]:not(:first-child)]:border-t', '[&>[data-slot=button]:not([data-variant]):not(:first-child)]:border-primary-foreground/20 [&>[data-slot=button]:not([data-variant]):not(:first-child)]:border-t', '[&>[data-slot=button][data-variant=secondary]:not(:first-child)]:border-border [&>[data-slot=button][data-variant=secondary]:not(:first-child)]:border-t', '[&>[data-slot=button][data-variant=destructive]:not(:first-child)]:border-t [&>[data-slot=button][data-variant=destructive]:not(:first-child)]:border-white/20', ], ], !attached && (orientation === 'vertical' ? 'gap-1' : 'gap-1.5'), className, )} {...props} > {children} </div> ) }, ) ButtonGroup.displayName = 'ButtonGroup'components/ui/button/button.variants.ts2.7 kB
import type { VariantProps } from 'class-variance-authority' import { cva } from 'class-variance-authority' /** * Variant definitions live in their own file (rather than the package * `index.ts`) so `Button.vue` can `import { buttonVariants } from * './button.variants'` without creating a circular dependency through the * index. See card.variants.ts for the same pattern + the SSR symptom that * motivated the split. */ export const buttonVariants = cva( "inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-[color,background-color,border-color,box-shadow,opacity,transform,scale] duration-150 active:scale-[0.97] active:duration-100 touch-manipulation disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", { variants: { variant: { default: 'bg-primary text-primary-foreground shadow-xs hover:bg-primary/90', destructive: 'bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60', outline: 'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50', secondary: 'bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80', ghost: 'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50', link: 'text-primary underline-offset-4 hover:underline', }, size: { default: 'h-9 px-4 py-2 has-[>svg]:px-3', sm: 'h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5', lg: 'h-10 rounded-md px-6 has-[>svg]:px-4', xs: 'h-7 rounded-md gap-1 px-2 has-[>svg]:px-1.5 text-xs', icon: 'size-9', 'icon-sm': 'size-8', 'icon-lg': 'size-10', // Square counterpart of `xs` (h-7). Dense data toolbars run at 28px and // had no icon-only tier to match, so icon controls sat 4px taller than // the buttons beside them. Icons inside carry their own size class. 'icon-xs': 'size-7', // Row-action tier: the hover-revealed copy control inside a two-line // table cell. Anything taller than the 20px text line it sits on makes // the row grow when the control appears. 'icon-2xs': 'size-5', }, }, defaultVariants: { variant: 'default', size: 'default', }, }, ) export type ButtonVariants = VariantProps<typeof buttonVariants>components/ui/button/index.ts0.2 kB
export { Button, type ButtonProps } from './Button' export { ButtonGroup, type ButtonGroupProps } from './ButtonGroup' export { buttonVariants, type ButtonVariants } from './button.variants'
Raw manifest:https://uipkge.dev/r/react/button.json