diff --git a/.changeset/swift-kiwis-wash.md b/.changeset/swift-kiwis-wash.md new file mode 100644 index 00000000000..b282c63ead9 --- /dev/null +++ b/.changeset/swift-kiwis-wash.md @@ -0,0 +1,5 @@ +--- +"@astrojs/starlight": minor +--- + +Add `LinkCard` component diff --git a/docs/src/content/docs/guides/components.mdx b/docs/src/content/docs/guides/components.mdx index 1b7638b0dd1..ee12879528a 100644 --- a/docs/src/content/docs/guides/components.mdx +++ b/docs/src/content/docs/guides/components.mdx @@ -125,6 +125,44 @@ Add the `stagger` attribute to shift the second column of cards vertically and a ::: +### Link Cards + +Use the `` component to link prominently to different pages. + +A `` requires a `title` and an [`href`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#href) attribute. You can optionally include a short `description` or other link attributes such as `target`. + +Group multiple `` components in `` to display cards side-by-side when there’s enough space. + +```mdx +import { LinkCard, CardGrid } from '@astrojs/starlight/components'; + + + + + + + +``` + +The above code generates the following on the page: + +import { LinkCard } from '@astrojs/starlight/components'; + + + + + + + + ### Icon import { Icon } from '@astrojs/starlight/components'; diff --git a/packages/starlight/components.ts b/packages/starlight/components.ts index 6fd711e8479..ac1c0f7bd25 100644 --- a/packages/starlight/components.ts +++ b/packages/starlight/components.ts @@ -3,3 +3,4 @@ export { default as CardGrid } from './user-components/CardGrid.astro'; export { default as Icon } from './user-components/Icon.astro'; export { default as Tabs } from './user-components/Tabs.astro'; export { default as TabItem } from './user-components/TabItem.astro'; +export { default as LinkCard } from './user-components/LinkCard.astro'; diff --git a/packages/starlight/style/util.css b/packages/starlight/style/util.css index 7451f6e00ac..57ed29d46df 100644 --- a/packages/starlight/style/util.css +++ b/packages/starlight/style/util.css @@ -41,3 +41,15 @@ display: block; } } + +/* +Flip an element around the y-axis when in an RTL context. +Primarily useful for things where we can’t rely on writing direction like icons. + + + +In a LTR context: → In a RTL context: ← +*/ +[dir='rtl'] .rtl\:flip:not(:where([dir='rtl'] [dir='ltr'] *)) { + transform: matrix(-1, 0, 0, 1, 0, 0); +} diff --git a/packages/starlight/user-components/LinkCard.astro b/packages/starlight/user-components/LinkCard.astro new file mode 100644 index 00000000000..683ac749407 --- /dev/null +++ b/packages/starlight/user-components/LinkCard.astro @@ -0,0 +1,65 @@ +--- +import Icon from './Icon.astro'; +import type { HTMLAttributes } from 'astro/types'; + +interface Props extends Omit, 'title'> { + title: string; + description?: string; +} + +const { title, description, ...attributes } = Astro.props; +--- + + + +