Skip to the content

Kongens Nytorv

Metro M1, M2 and M3.

Departures

  • 5C Husum Torv 08:14
  • 5C Lufthavnen 08:17
  • 350S Ballerup St. 08:21

Props

NameTypeDefaultDescription
title*ReactNode—What the section is about, in a word or two and in sentence case: "Departures". Set in capitals by the style; it names the section for screen readers. Required. Replaces the HTML title attribute
childrenReactNode—The section's content, below the title
actionReactNode—One small action at the end of the header, such as a small outline LinkButton to everything the section lists
slotProps{ header?: ComponentProps<"div", {}, HTMLProps> | undefined; title?: ComponentProps<"h3", {}, HTMLProps> | undefined; action?: ComponentProps<"div", {}, HTMLProps> | undefined; content?: ComponentProps<"div", {}, HTMLProps> | undefined; }—Props for each part: header, title, action, content.
title (required)ReactNode, default —
What the section is about, in a word or two and in sentence case: "Departures". Set in capitals by the style; it names the section for screen readers. Required. Replaces the HTML title attribute
childrenReactNode, default —
The section's content, below the title
actionReactNode, default —
One small action at the end of the header, such as a small outline LinkButton to everything the section lists
slotProps{ header?: ComponentProps<"div", {}, HTMLProps> | undefined; title?: ComponentProps<"h3", {}, HTMLProps> | undefined; action?: ComponentProps<"div", {}, HTMLProps> | undefined; content?: ComponentProps<"div", {}, HTMLProps> | undefined; }, default —
Props for each part: header, title, action, content.

Use it

import { Section } from '@mylder/perron'

Ask your agent

search_docs({ query: "Section" })

Keyboard and ARIA

Section has no keys of its own and is never focusable. The caller's action, then the caller's content, are reached in reading order.

KeyDoesFrom
TabMoves to the first focusable element in the action, then on into the contentThe browser
Shift+TabMoves back through the content and the action, out to what came before the SectionThe browser
ElementRoleAccessible name fromStates announced
rootregion, from a section with an accessible name; generic when render makes it a divaria-labelledby, the title's id: its textNone
headerNone (generic div)NoneNone
titleheading, level 3, or the level slotProps.title.render givesIts text, from title, read as written in sentence caseNone
actionNone (generic div); the caller's controls carry their own rolesThe caller's controls' own namesTheirs
contentNone (generic div); the caller's content carries its own rolesNoneNone

What axe won't catch, from the contract, each with how this component meets it:

  • Everything the eye is told, the ear is told, for every shape each prop accepts: the eye gets a grouping under a heading, and the ear the same heading and a region named by it; the capitals are style over sentence-case text (CR-7), so a screen reader reads the word, not its letters.
  • Every landmark and named region has an accessible name: the root is a section named by its own title through aria-labelledby (CR-2), and the Default story's play checks the region's name.
  • Every default label can be overridden: none here; Section owns no string.
  • Every shape the type accepts renders, in every variant: title, action and children each render a string, an element and an array; the title is a heading, so it takes phrasing content, and content and action are divs, so block content such as a list is valid inside them.
  • A hidden copy kept for animation is aria-hidden, and a collapsed region is inert: none here; nothing animates or collapses.
  • Native semantics first: a native section and h3, with aria-labelledby the only ARIA, naming the region from the heading that is already there; the action holds the caller's own a href or button.
  • Focus moves in reading order and returns on close: the title, the action and the content follow each other in the DOM as on screen, including when the header wraps (CR-6); Section never moves focus, and nothing in it closes.
  • Every target is at least size.target-min square: Section has no target of its own; the action's targets are the caller's components, which keep their own sizes (a small LinkButton is size.button-sm).
  • Loops stop when the system asks for less motion: none here; nothing moves.

Owned strings

No owned strings: every word Section shows or announces comes from the caller, through title, action and children, and the region's name is the title.

Do and don't

For a caller using the component, with the reason. Each row is a rule: a must row's Don't is never right, a should row's needs a reason, and Checked by says what catches the Don't in a caller's code.

RuleLevelDoDon'tChecked by
DD-1mustWrite the title in sentence case, a word or two, and let the style set the capitals: "Departures"Type the title in capitals: a screen reader may spell it out letter by letter, and content design writes source text in sentence casereview
DD-2mustGive the title the level that fits the page's outline through slotProps.title.render: h3 under a panel's h2, h4 inside an h3's sectionSkip a level, or wrap a heading element inside title: the part is already a heading, and a heading inside a heading is invalidreview
DD-3mustPut one small, neutral action in the header, such as a small outline LinkButton to the whole listPut the panel's main action, or a brand button, in a section's header: a screen has one brand action, and it belongs to the panelreview
DD-4shouldGive the content one block per child: a paragraph, a list, a row of buttonsPass a sentence with a link in it straight as children: each element becomes a block of its own, so wrap the sentence in a paragraphreview
DD-5shouldSpace sections apart in the caller's layout, space.600 between blocks of a paneAdd margins or padding to Section with raw values, or rely on it for the space between sections: it adds nonereview
DD-6shouldWrap a section in a Surface when it needs a card or a box of its ownAdd a fill, border or shadow to Section through className: a box is Surface's job, and the ladder lives therereview
DD-7shouldRender the root as a div through render when the group is too small to be worth a region of its ownLeave a screen full of tiny named regions: a screen reader's landmark list then says less than its headingsreview
DD-8mustLeave a group that opens and closes to a collapsible component, built on Base UI's CollapsibleBuild a collapsible group from Section by hiding its content: it brings no button, state or keysreview
DD-9mustSet the title's id through slotProps.title.idPut an id on the element in slotProps.title.render: it replaces the generated one and the region loses its namereview