Skip to content

CSS: card

.instui-card — Ein overflatebehaldar som tek imot vilkårleg innhald.

Variant styrer korleis direkte born blir stilsette: content (standard) let dei stå uformaterte; container stabler dei som avgrensa, polstra seksjonar. Polstringa skalerer med visningsvindauget sin breidde og er den same for begge variantar. Size er heilt responsiv — polstring og border-radius aukar automatisk ved 320px (20rem) og 640px (40rem) via standard min-width media queries; ingen storleiksklasse er naudsynt. Pair with @pantoken/components for heading, button, and other inline components.

Tilgjenge

Bruk <article> som kort-element når kortet er ein sjølvstendig innhaldsenhet; bruk <section> når det er gruppert innanfor eit større landemerke. I -variant-container, føretrekk <section>-element som direkte born slik at kvar avgrensa region får semantisk meining.

Bruk

@import "@pantoken/plugin-custom-components/custom-components.css";

css
@import "@pantoken/plugin-custom-components/custom-components.css";

Døme

Innhaldskort

html
<article class="instui-card">
  <h2 class="instui-heading -h3">Card title</h2>
  <p>Content here.</p>
  <button class="instui-button">Action</button>
</article>

Containerkort

html
<article class="instui-card -variant-container">
  <section>First section</section>
  <section>Second section</section>
</article>

Struktur

text
.instui-card
  ‹content›
flowchart TD n0[".instui-card"]:::cssdoc-root n1[/"‹content›"/]:::cssdoc-slot n0 --> n1 classDef cssdoc-root stroke-width:1px; classDef cssdoc-part stroke-width:1px; classDef cssdoc-slot stroke-width:1px; classDef cssdoc-component stroke-width:1px;

Modifikatorar

ModifikatorSkildring
.-variant-containerContainerkort; direkte born blir avgrensa, polstra seksjonar.
.-variant-contentStandard innhaldskort; born er uformaterte. Standard når ingen variant er sett.

Vilkår

TypeFørespurnadSkildring
media(min-width: 20rem)
media(min-width: 40rem)

Token brukt

TokenTypeVerdi
--instui-component-card-background-color<color>LightDarklight-dark(#ffffff, #1C222B)
--instui-component-card-border-radius-base-lg<length>1rem
--instui-component-card-border-radius-base-md<length>1rem
--instui-component-card-border-radius-base-sm<length>0.75rem
--instui-component-card-border-radius-nested-lg<length>0.75rem
--instui-component-card-border-radius-nested-md<length>0.5rem
--instui-component-card-border-radius-nested-sm<length>0.5rem
--instui-component-card-nested-border-color<color>LightDarklight-dark(#E8EAEC, #2D3D49)
--instui-component-card-padding-base-lg<length>1.5rem
--instui-component-card-padding-base-md<length>1rem
--instui-component-card-padding-base-sm<length>0.75rem
--instui-component-card-padding-nested-lg<length>1rem
--instui-component-card-padding-nested-md<length>0.75rem
--instui-component-card-padding-nested-sm<length>0.5rem
--instui-component-shared-tokens-spacing-gap-cards-nested-containers-lg<length>1rem
--instui-component-shared-tokens-spacing-gap-cards-nested-containers-md<length>0.75rem
--instui-component-shared-tokens-spacing-gap-cards-nested-containers-sm<length>0.5rem
--instui-component-shared-tokens-stroke-width-sm<length>0.0625rem
--instui-elevation-cardnone | <shadow>#

Nettlesarstøtte

  • @scope er Baseline 2023 Newly Available; kortet fell tilbake til eit uskopa, flatt stilark i eldre nettlesarar utan tap av synleg styling.

Relatert

  • heading — Plasser direkte i kortet eller inne i ein containerseksjon.
  • button — Plasser direkte i kortet eller inne i ein containerseksjon.
  • img — Plasser direkte i kortet som ein medieregion.
  • badge — Plasser direkte i kortet som ein statusindikator.

Sjå òg