Skip to main content

Table of Contents

Preview
View as Markdown

A table of contents that highlights the headings you are reading.

Delivery

Orders placed before 2 pm on a working day ship the same day. You get a tracking link by email once the parcel leaves the warehouse, and you can follow it until the courier hands it over at your door.

Returns

You can return unworn items within 30 days. Print the return label from your order confirmation and drop the parcel at any post office. Keep the receipt of the post office until your refund has arrived.

Payment

We accept credit card, PayPal and invoice. Your card is charged when the order ships, not when you place it, so an item that is out of stock never costs you anything.

Contact

Write to support@example.com or call us on weekdays between 9 am and 5 pm. We answer emails within one working day, and a call is quicker for questions about a parcel on its way.

<primitives:toc.root>
    <primitives:toc.title />
    <primitives:toc.list>
        <primitives:toc.indicator />
        <primitives:toc.item>
            <primitives:toc.link />
        </primitives:toc.item>
    </primitives:toc.list>
</primitives:toc.root>
typo3 ui:add toc

Read more about installing Components and Primitives.

items takes TocItem objects or arrays with a value (the id of the heading element) and a depth. A TocItem also carries the label for your template and for client scripts.

use Jramke\FluidPrimitives\Domain\Dto\TocItem;

$items = array_map(
    static fn(array $header) => new TocItem(value: 'c' . $header['uid'], depth: 2, label: $header['header']),
    $contentElements,
);
<ui:toc.root items="{items}">
    <ui:toc.list>
        <f:for each="{items}" as="item">
            <ui:toc.item value="{item.value}"><ui:toc.link>{item.label}</ui:toc.link></ui:toc.item>
        </f:for>
    </ui:toc.list>
</ui:toc.root>

List the depth of each heading in items: 2 for an h2, 3 for an h3. An item exposes it as the --depth CSS variable, which the ui:toc.item of the registry turns into an indent.

Delivery

Orders placed before 2 pm on a working day ship the same day. You get a tracking link by email once the parcel leaves the warehouse, and you can follow it until the courier hands it over at your door.

Delivery times

Parcels reach most addresses in Germany within two working days, the rest of Europe takes up to five. Islands and remote regions can take a day or two longer, which the tracking link shows.

Shipping costs

Shipping is free from 50 EUR. Below that it costs 4.90 EUR within Germany and 9.90 EUR for the rest of Europe. The costs show in your basket before you pay.

Returns

You can return unworn items within 30 days. Print the return label from your order confirmation and drop the parcel at any post office. Keep the receipt of the post office until your refund has arrived.

Refunds

We refund the price of the items to the payment method you used. The shipping costs come back too if you return the whole order, otherwise they stay with the items you keep.

Refund times

A refund arrives within five working days after we receive the parcel. You get an email as soon as we have booked it, and your bank may need a few more days to show it.

Contact

Write to support@example.com or call us on weekdays between 9 am and 5 pm. We answer emails within one working day, and a call is quicker for questions about a parcel on its way.

Place a ui:toc.indicator in the list. It follows the active links through the --top, --height, --left and --width CSS variables of the root, and the list is its positioning context.

Delivery

Orders placed before 2 pm on a working day ship the same day. You get a tracking link by email once the parcel leaves the warehouse, and you can follow it until the courier hands it over at your door.

Returns

You can return unworn items within 30 days. Print the return label from your order confirmation and drop the parcel at any post office. Keep the receipt of the post office until your refund has arrived.

Refunds

We refund the price of the items to the payment method you used. The shipping costs come back too if you return the whole order, otherwise they stay with the items you keep.

Payment

We accept credit card, PayPal and invoice. Your card is charged when the order ships, not when you place it, so an item that is out of stock never costs you anything.

Contact

Write to support@example.com or call us on weekdays between 9 am and 5 pm. We answer emails within one working day, and a call is quicker for questions about a parcel on its way.

Each link draws a segment of the rail beside it, and the segment of an active link turns dark. A heading one level deeper steps the rail in, with a curve where the level changes.

Delivery

Orders placed before 2 pm on a working day ship the same day. Later orders leave the warehouse the next morning, and we do not ship on Sundays or public holidays.

Returns

You can return unworn items within 30 days. They need their tags and the original packaging, and we check them when the parcel arrives at our warehouse.

Return label

Print the label from your order confirmation and stick it on the parcel. If you have no printer, show the QR code in the email at any post office and they print it for you.

Return window

The 30 days start on the day the parcel arrives, not on the day you ordered. Send the items back within that time, and we still accept them if the parcel is on its way.

Payment

We accept credit card, PayPal and invoice. You pick one at the end of the checkout, and you can change it as long as the order has not shipped.

Credit card

Your card is charged when the order ships, not when you place it. If the payment fails, we email you a link to try another card before we cancel anything.

Invoice

You get the invoice with the parcel and a second copy by email. Invoice payment is available from your second order, and only for orders up to 500 EUR.

Due date

Pay within 14 days of the invoice date. The bank details are on the invoice, so please add the invoice number as the reference, otherwise we cannot match your payment.

Contact

Write to support@example.com on weekdays and we answer within one working day. Please add your order number, so we can find your order without asking again.

Put the list into a ui:collapsible. The trigger shows the active heading and how far you are, so the list can stay closed. The script mounts the Toc itself and updates the summary from onActiveChange: the --progress of the ring, the number and the label of the active heading.

Ingredients

Mix 500 g flour, 10 g salt, 7 g dry yeast and 350 ml lukewarm water. The dough is sticky, so keep a bowl of water nearby to wet your hands. Use bread flour if you can, it holds the shape better.

Kneading

Knead for ten minutes until the dough stops sticking to your hands, then let it rest for an hour. It should double in size, and small bubbles show on the surface when it is ready.

Shaping

Fold the dough into a tight ball, place it seam side up in a floured basket and cover it. Let it rise for another hour, until a finger pressed into it leaves a dent that fills back slowly.

Baking

Bake at 240 C for 20 minutes with a pan of water on the rack below, then 20 minutes at 200 C. The crust should be deep brown, and the loaf sounds hollow when you tap its bottom.

Storing

Let the loaf cool for an hour before cutting. It stays fresh for three days in a linen bag, and you can slice and freeze what you do not eat to toast it later.

The following tables cover the available props of the Fluid Primitives. For a full list of available client side props and methods, see the Zag.js Machine API.

Wraps the table of contents, provides its state and takes the items. Renders a <nav> element.

NameDescriptionRequiredDefault
itemsarray|Domain\Dto\TocItem[]
The headings of the page, a list of `TocItem` objects or of arrays with a `value` (the id of the heading) and a `depth` (its level, e.g. `2` for an `h2`). Every `ui:toc.item` takes its depth from here.
Yes
-
defaultActiveIdsstring[]
The ids of the headings that are active when rendered, until the first observation replaces them. Use when you don't need to control the active headings.
No
-
rootMarginstring
The root margin of the IntersectionObserver. It sets the area of the viewport in which a heading counts as visible.
No
'-20px 0% -40% 0%'
thresholdfloat|float[]
The threshold of the IntersectionObserver. `0` makes a heading active as soon as a single pixel of it is inside the root margin.
No
0
scrollElstring
A CSS selector of the scroll container the headings sit in. Defaults to the viewport of the document.
No
-
autoScrollboolean
Whether the table of contents scrolls the first active item into view when the active headings change. It scrolls every scrollable ancestor of the item, the page included, so turn it off for a list that does not scroll itself.
No
true
scrollBehaviorEnum\ScrollBehavior
The scroll behavior of the auto-scroll of the list and of a click on a link. A link only scrolls by itself when `scrollEl` is set, otherwise the browser follows its hash. Smooth scrolling is skipped for a visitor who prefers reduced motion.
No
Smooth
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
rootIdstring
The root ID of the component, used for hydration and identification.
No
-
idsarray
The IDs of of the component parts for composition.
No
[]
autoMountboolean
Whether the client initializes the component on its own. Set it to false to mount it yourself with `mount()`
No
true
classstring
The CSS class(es) to be applied to the component.
No
-

Labels the table of contents. Renders an <h2> element, set level for another heading level.

NameDescriptionRequiredDefault
levelinteger
The heading level to render for the title.
No
2
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

Wraps the items and is the positioning context of the indicator. Renders a <ul> element.

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

One heading of the page, identified by its value. Renders an <li> element.

NameDescriptionRequiredDefault
valuestring
The id of the heading the item points to. It has to be one of the `items` of the root, which also set the depth of the item. The depth is available as the `--depth` CSS variable to indent the item.
Yes
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-toc-item<uid>
data-valueThe value of the item
data-depthThe depth of the item
data-activePresent when active or pressed
data-first
data-last

Links to the heading of its item. Renders an <a> element.

NameDescriptionRequiredDefault
hrefstring
The target of the link. Defaults to the hash of the item's heading, `#value`.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-toc-link<uid>
data-valueThe value of the item
data-activePresent when active or pressed

Follows the active items. Renders a <div> element.

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-
NameTypeDescription
activeIdsstring[]All currently active (visible) heading ids
activeItemsTocItem[]The active (visible) TOC items
itemsTocItem[]The resolved items list
setActiveIds(value: string[]) => voidManually set the active heading ids
scrollTo(value: string, details?: ScrollToDetails | undefined) => voidScrolls to the heading with the given id.
getItemState(props: ItemProps) => ItemStateReturns the state of a TOC item
getIndicatorState() => IndicatorStateReturns the state of the indicator