Layout and utilities
Small CSS classes for the layout work every screen needs: stacks, rows, responsive grids, sidebars, fixed ratios, scroll areas and a few page helpers. They respond to the space they are given, so most screens need no media queries.
Layout
Stack
Children in a column with even spacing. Set the space with --pm-gap.
Cluster
Items in a row that wrap when space runs out: button rows, tags, toolbars. pm-spacer pushes what follows to the end.
Grid
As many equal columns as fit. --pm-grid-min is the narrowest a column may be; no media queries needed.
Split
A sidebar next to main content. The sidebar is --pm-side wide; when the main part would get narrower than --pm-split-min, the two stack.
Switcher
A row of equal parts that turns into a column all at once when the container is narrow (never two-plus-one).
Container and centre
pm-container centres page content with side padding (--pm-container sets the width). pm-center centres one child both ways.
Horizontal scroll
Wide content scrolls inside its box instead of widening the page. Add tabindex="0" so keyboard users can scroll it.
Helpers
Aspect ratio
Keeps a box (image, video, map, embed) at a fixed ratio so nothing jumps when it loads. Set --pm-ratio.
Scroll area
A scrolling box with thin themed scrollbars; data-fade fades the edges where more content is hidden. --pm-scroll-height sets the height.
Disclosure
The native <details> element, styled: keyboard and screen-reader support come from the browser. For a group where one opens at a time, use Accordion.
Shipping and returns
Orders ship within two working days. Returns are free for 30 days.
Choice cards
Any radio or checkbox label becomes a selectable card with data-card. In components: variant="card" on a radio or checkbox group.
Description list
Label and value pairs on a native <dl>. Add data-divided for lines and data-layout="vertical" to stack.
- Order
- #1042
- Status
- Shipped
- Total
- $128.00
Sticky header
Keeps a header or action bar in view while its section scrolls. --pm-sticky-offset leaves room for a fixed app bar, data-edge="bottom" pins a footer instead. Wrap the content in pm-sticky-inner to get a shadow only while it is stuck (browsers with scroll-state queries).
INV-1048
INV-1047
INV-1046
INV-1045
INV-1044
INV-1043
INV-1042
INV-1041
Sticky side column
A summary, filter list or table of contents that stays in view beside a long column (an order summary next to a checkout form). --pm-sticky-top is the distance from the top; it has no background of its own.
Pane
A column as tall as the screen allows, for chat and other screens where the list scrolls and the input stays put. pm-pane-body is the part that scrolls; --pm-pane-offset is the height of what is above and below the pane.
Table of contents
Links to the sections of a long page. Mark the section being read with aria-current (an IntersectionObserver does it in the article template).
Placeholder art
A tinted box with an icon where a product photo or illustration will go, so a page looks finished before the images exist. data-tone picks the colour, data-size="sm" makes a thumbnail.
Marquee
A slowly moving row (logos, quotes). It pauses on hover and focus, and becomes a row you scroll yourself when reduced motion is on. Repeat the items once so the loop is seamless, and hide the copy from screen readers.
Floating action button
Add pm-fab to a button for the main action of a screen. It stays in the bottom corner, above the tab bar in native phone mode. data-position="start | center" moves it. (Shown in place here.)
Visually hidden
Text for screen readers only: names for icon buttons, extra context in tables, skip links (it shows again when focused).
Utility classes
Utility classes (opt-in)
One more stylesheet with 273 small classes for spacing, size, colour, corners, position and effects. It is not part of @prismora/css: import it when you want it. Every value is a theme token, so the classes follow your theme, dark mode and surface. They sit in the last cascade layer and win over component styles without !important.
Padding
Steps of the spacing scale: pm-p-4 all round, pm-px-4 left and right, pm-py-2 top and bottom, pm-pt-, pm-pb-, pm-ps- (start) and pm-pe- (end).
pm-p-0pm-p-1pm-p-2pm-p-3pm-p-4pm-p-5pm-p-6pm-p-8pm-p-10pm-p-12pm-p-16pm-px-0pm-px-1pm-px-2pm-px-3pm-px-4pm-px-5pm-px-6pm-px-8pm-px-10pm-px-12pm-px-16pm-py-0pm-py-1pm-py-2pm-py-3pm-py-4pm-py-5pm-py-6pm-py-8pm-py-10pm-py-12pm-py-16pm-pt-0pm-pt-1pm-pt-2pm-pt-3pm-pt-4pm-pt-5pm-pt-6pm-pt-8pm-pt-10pm-pt-12pm-pt-16pm-pb-0pm-pb-1pm-pb-2pm-pb-3pm-pb-4pm-pb-5pm-pb-6pm-pb-8pm-pb-10pm-pb-12pm-pb-16pm-ps-0pm-ps-1pm-ps-2pm-ps-3pm-ps-4pm-ps-5pm-ps-6pm-ps-8pm-ps-10pm-ps-12pm-ps-16pm-pe-0pm-pe-1pm-pe-2pm-pe-3pm-pe-4pm-pe-5pm-pe-6pm-pe-8pm-pe-10pm-pe-12pm-pe-16
Margin
pm-mt-4, pm-mb-4, pm-ms-2 (start), pm-me-2 (end), pm-m-0, and pm-mx-auto to centre a block. Prefer pm-stack and pm-gap-* for space between siblings.
pm-mt-0pm-mt-1pm-mt-2pm-mt-3pm-mt-4pm-mt-5pm-mt-6pm-mt-8pm-mt-10pm-mt-12pm-mt-16pm-mb-0pm-mb-1pm-mb-2pm-mb-3pm-mb-4pm-mb-5pm-mb-6pm-mb-8pm-mb-10pm-mb-12pm-mb-16pm-ms-0pm-ms-1pm-ms-2pm-ms-3pm-ms-4pm-ms-5pm-ms-6pm-ms-8pm-ms-10pm-ms-12pm-ms-16pm-me-0pm-me-1pm-me-2pm-me-3pm-me-4pm-me-5pm-me-6pm-me-8pm-me-10pm-me-12pm-me-16pm-m-0pm-mx-autopm-ms-autopm-me-autopm-mt-auto
Display and visibility
pm-hide-phone, pm-hide-tablet and pm-hide-desktop take a thing off one size of screen (under 40rem, 40 to 64rem, 64rem and up); pm-show-phone shows it on phones only.
pm-blockpm-inline-blockpm-inlinepm-flexpm-inline-flexpm-d-gridpm-nonepm-invisiblepm-hide-phonepm-hide-tabletpm-hide-desktoppm-show-phone
Flex and grid
pm-row and pm-col set the direction, pm-wrap lets items wrap, pm-flex-1 shares the free space. pm-cols-3 is a grid of three equal columns; pm-span-2 and pm-span-full size an item. (Alignment and gaps: pm-items-*, pm-justify-*, pm-gap-*.)
pm-rowpm-colpm-wrappm-flex-nowrappm-flex-1pm-flex-nonepm-self-startpm-self-centerpm-self-endpm-self-stretchpm-place-centerpm-justify-startpm-justify-aroundpm-justify-evenlypm-cols-1pm-cols-2pm-cols-3pm-cols-4pm-cols-5pm-cols-6pm-cols-12pm-span-2pm-span-3pm-span-4pm-span-6pm-span-fullpm-order-firstpm-order-last
Size
pm-w-full, pm-h-full, pm-h-screen (the visible screen, also on phones), pm-min-w-0 (lets a flex or grid child shrink), pm-max-w-sm to pm-max-w-xl and pm-max-w-prose, and fixed ratios.
pm-w-fullpm-w-autopm-w-fitpm-h-fullpm-h-screenpm-min-h-screenpm-min-w-0pm-max-w-xspm-max-w-smpm-max-w-mdpm-max-w-lgpm-max-w-xlpm-max-w-prosepm-ratio-squarepm-ratio-videopm-ratio-photopm-ratio-portraitpm-object-coverpm-object-contain
Background and border
Backgrounds of the theme (pm-bg-canvas, -surface, -subtle, -muted, -inverse), tinted ones (pm-bg-accent, -success, -warning, -danger, -info), and hairline borders.
pm-bg-canvaspm-bg-surfacepm-bg-subtlepm-bg-mutedpm-bg-inversepm-bg-accentpm-bg-successpm-bg-warningpm-bg-dangerpm-bg-infopm-bg-accent-solidpm-bg-success-solidpm-bg-warning-solidpm-bg-danger-solidpm-bg-info-solidpm-text-mutedpm-text-infopm-borderpm-border-strongpm-border-tpm-border-bpm-border-spm-border-epm-border-dashedpm-border-0pm-border-accentpm-border-successpm-border-warningpm-border-dangerpm-border-info
Corners and shadows
pm-rounded-sm to pm-rounded-2xl, pm-rounded-full, pm-rounded-none, and the six elevations pm-shadow-0 to pm-shadow-5. They follow the theme: a sharp theme stays sharp.
pm-rounded-xspm-rounded-smpm-rounded-mdpm-rounded-lgpm-rounded-xlpm-rounded-2xlpm-rounded-fullpm-rounded-nonepm-shadow-0pm-shadow-1pm-shadow-2pm-shadow-3pm-shadow-4pm-shadow-5pm-ringpm-opacity-50pm-opacity-70
Position and overflow
pm-relative, pm-absolute, pm-fixed, pm-inset-0, the corners (pm-top-0, pm-end-0…), pm-overflow-auto and -hidden, a sideways snap lane (pm-snap-x with pm-snap-start or pm-snap-center on the items) and pm-no-scrollbar.
pm-relativepm-absolutepm-fixedpm-staticpm-inset-0pm-top-0pm-bottom-0pm-start-0pm-end-0pm-z-0pm-z-1pm-z-10pm-isolatepm-overflow-autopm-overflow-hiddenpm-overflow-clippm-overflow-y-autopm-snap-xpm-snap-startpm-snap-centerpm-no-scrollbar
Safe areas
Padding that keeps content out from under a notch, rounded corners or the home indicator, on top of what you set with --pm-pad: pm-safe-top, pm-safe-bottom, pm-safe-x.
pm-safe-toppm-safe-bottompm-safe-x
Interaction
pm-pressable sinks a little when pressed, pm-hover-lift rises under the pointer (not on touch screens, and not with reduced motion), pm-pointer, pm-select-none, pm-events-none.
pm-pointerpm-select-nonepm-select-allpm-events-nonepm-transitionpm-pressablepm-hover-lift
Effects
Finishing touches for hero sections and cards: pm-glow, pm-gradient-border, pm-shimmer (a light sweeping over, for "new" or loading), pm-glass, pm-spotlight (a soft light; set --pm-spot-x and --pm-spot-y to follow the pointer), faded edges (pm-fade-x, pm-fade-y, pm-fade-bottom) and backdrops (pm-dots, pm-grid-lines).
pm-glowpm-gradient-borderpm-glasspm-spotlightpm-fade-xpm-fade-ypm-fade-bottompm-dotspm-grid-linespm-shimmer
JavaScript
Helpers
Small functions that every app ends up writing, tested and ready: 39 of them, with no dependencies. Import from @prismora/elements/utils, or one file at a time (@prismora/elements/utils/format); a bundler keeps only what you call. They do nothing on a server, so they are safe in code that also renders there.
Browser utils/dom
Keyboard shortcuts (mod+k, sequences like g o), copying, media queries and breakpoints, visibility, scroll lock, focus trap, long press and swipe. Each returns the function that undoes it, for your framework's cleanup hook.
hotkeyhotkeyLabelcopyTextwatchMediabreakpointwatchBreakpointprefersReducedMotioninViewlockScrollfocusabletrapFocuslongPressswipe
Stored state utils/storage
A value that survives a reload, follows other tabs and can be subscribed to: table density, a dismissed tip, the last filter.
persisted
Formatters utils/format
Numbers, money, sizes, durations, dates, relative time and lists in the reader's language, on top of Intl.
formatNumberformatCurrencyformatPercentformatCompactformatBytesformatDurationformatDateformatRelativeformatListinitialspluralize
Lists utils/collection
Sort the way people read ("item 2" before "item 10"), group, total, split into pages and search with typos forgiven.
sortBygroupByuniqueBysumBychunkfuzzyScorefuzzyFilter
Files utils/download
Save rows as CSV (quoted properly, and safe against spreadsheet formulas in user input), JSON or any text.
toCsvdownloadCsvdownloadJsondownloadFile
Timing utils/timing
Rate limiters for search fields, autosave, scroll and resize handlers.
debouncethrottlesleep
Related
Text utilities are on the Typography page. The app shell (pm-app with a sidebar that becomes a tab bar or drawer on phones) is covered in Mobile, and tokens for spacing, radius and elevation in Tokens.