Summit Provider
The Summit Provider supplies translated labels and a date locale to the components that read them.
By default, the components use English labels and US English dates, so a product in English that shows US dates doesn’t need the provider.
Labels
A group of defaultLabels belongs to one component, except toast, which Sonner and Toast share.
| Key | Default | Placement |
|---|---|---|
breadcrumb.label | “breadcrumb” | The aria-label of the nav of a Breadcrumb |
breadcrumb.more | “More” | Visually hidden text in BreadcrumbEllipsis |
carousel.roleDescription | “carousel” | The aria-roledescription of a Carousel |
carousel.slideRoleDescription | “slide” | The aria-roledescription of each CarouselItem |
carousel.previousSlide | “Previous slide” | The name of CarouselPrevious |
carousel.nextSlide | “Next slide” | The name of CarouselNext |
combobox.clear | “Clear” | The aria-label of ComboboxClear in a Combobox |
combobox.openPopup | “Open popup” | The aria-label of the trigger button in ComboboxInput |
combobox.remove | “Remove” | The aria-label of the remove button on a ComboboxChip |
command.title | “Command palette” | The visually hidden title of CommandDialog in Command, unless title is passed |
command.description | “Search for a command to run…” | The visually hidden description of CommandDialog, unless description is passed |
command.suggestions | “Suggestions” | The aria-label of CommandList |
dialog.close | “Close” | The name of the close button of a Dialog and the label of the footer’s close button |
messageScroller.scrollToEnd | “Scroll to end” | The name of MessageScrollerButton in a Message Scroller at direction="end", the default |
messageScroller.scrollToStart | “Scroll to start” | The name of MessageScrollerButton at direction="start" |
messageScroller.label | “Messages” | The aria-label of MessageScrollerViewport |
pagination.label | “pagination” | The aria-label of the nav of a Pagination |
pagination.previous | “Previous” | The text of PaginationPrevious, shown from 640px, unless text is passed |
pagination.previousAria | “Go to previous page” | The aria-label of PaginationPrevious, unless text is passed |
pagination.next | “Next” | The text of PaginationNext, shown from 640px, unless text is passed |
pagination.nextAria | “Go to next page” | The aria-label of PaginationNext, unless text is passed |
pagination.morePages | “More pages” | Visually hidden text in PaginationEllipsis |
sheet.close | “Close” | The name of the close button of a Sheet |
sidebar.title | “Sidebar” | The visually hidden title of the Sheet that a Sidebar opens in below 768px |
sidebar.description | “Displays the mobile sidebar.” | The visually hidden description of that Sheet |
sidebar.toggle | “Toggle sidebar” | The name of SidebarTrigger |
sidebar.collapse | “Collapse sidebar” | The aria-label and the Tooltip of SidebarRail while the Sidebar is open |
sidebar.expand | “Expand sidebar” | The aria-label and the Tooltip of SidebarRail while the Sidebar is collapsed |
spinner.loading | “Loading” | The aria-label of a Spinner |
toast.close | “Close toast” | The aria-label of the close button of a toast, in Sonner and in Toast |
toast.loading | “Loading…” | The title of the loading toast of toast.promise in Sonner, unless loading is passed |
Most of these strings are accessible names. Screen readers announce them, but they are never shown on screen, so a missing translation won’t appear in a visual review.
Date Locale
dateLocale accepts a Locale from date-fns. The Calendar passes it to React DayPicker, which reads the names of months and weekdays and the first day of the week from it. If dateLocale isn’t set, DayPicker uses US English.
If you pass locale to a Calendar, it overrides the provider for that Calendar. No other component reads dateLocale, so a date that the product formats itself isn’t affected.
Installation
npx shadcn@latest add @summit/summit-providerThe CLI also adds the provider with each component that reads it.
Usage
Render the provider once, above every Summit component. It renders no element.
import { SummitProvider } from '@/components/ui/summit-provider';
<SummitProvider labels={labels}>{children}</SummitProvider>;If the product uses React Server Components, build the props and render the provider in a file marked 'use client'. summit-provider.tsx is a client module, so a server component can’t spread defaultLabels. A locale contains functions, which can’t be passed from a server component to a client component.
Translate the Labels
labels replaces defaultLabels as a whole, and its type requires every key. To keep the groups that aren’t translated yet, spread defaultLabels, and then replace whole groups.
import { defaultLabels } from '@/components/ui/summit-provider';
import type { SummitLabels } from '@/components/ui/summit-provider';
const labels: SummitLabels = {
...defaultLabels,
dialog: { close: 'Fermer' },
sheet: { close: 'Fermer' },
};Declare the object outside the component, or memoize it on the active language. If the object is built during render, it is new each time, and every component that reads the provider will render again.
Set the Date Locale
Import a locale from react-day-picker/locale, and pass it to dateLocale. It is a date-fns locale with the accessible names of the Calendar added, for example “Go to the Next Month”. If you import the locale from date-fns/locale, those names stay in English.
import { frCA } from 'react-day-picker/locale';
<SummitProvider dateLocale={frCA}>{children}</SummitProvider>;Read a Label
useSummit returns labels and dateLocale.
import { Button } from '@/components/ui/button';
import { useSummit } from '@/components/ui/summit-provider';
function DismissButton() {
const { labels } = useSummit();
return <Button variant="outline">{labels.dialog.close}</Button>;
}API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
labels | SummitLabels | defaultLabels | All labels. They replace the defaults and aren’t merged. |
dateLocale | Locale from date-fns | None | The locale of a Calendar that has no locale of its own |
children | ReactNode | None | The app |