Moons
Io, Europa, Ganymede
Components let you easily reuse a piece of UI or styling consistently. Examples might include a link card or a YouTube embed. ChaiDocs supports the use of components in MDX files and provides some common components for you to use.
Learn more about building components in the Astro Docs.
You can use a component by importing it into your MDX file and then rendering it as a JSX tag.
These look like HTML tags but start with an uppercase letter matching the name in your import statement:
---title: Welcome to my docs---
import { Icon } from '@astrojs/starlight/components';import AboutUs from '@/components/branding/about-us.astro';
<Icon name="open-book" />
<AboutUs>Components can also contain **nested content**.</AboutUs>Because ChaiDocs is powered by Astro, you can add support for components built with any supported UI framework (React, Preact, Svelte, Vue, Solid, and Alpine) in your MDX files. Learn more about using components in MDX in the Astro docs.
ChaiDocs provides built-in components for common documentation use cases.
These components are available from the @astrojs/starlight/components package in MDX files.
See the sidebar for a list of available components and how to use them.
ChaiDocs applies default styling to your Markdown content, for example, adding margin between elements.
If these styles conflict with your component’s appearance, set the not-content class on your component to disable them.
<div class="not-content"> <p>Not impacted by ChaiDocs’s default content styling.</p></div>Use the ComponentProps type from astro/types to reference the Props accepted by a component even if they are not exported by the component itself.
This can be helpful when wrapping or extending an existing component.
The following example uses ComponentProps to get the type of the props accepted by ChaiDocs’s built-in Badge component:
---import type { ComponentProps } from 'astro/types';import { Badge } from '@astrojs/starlight/components';
type BadgeProps = ComponentProps<typeof Badge>;---To display content in a box matching ChaiDocs’s styles, use the <Card> component.
Moons
Io, Europa, Ganymede
import { Card } from '@astrojs/starlight/components';Display a card using the <Card> component and provide a title for the card.
import { Card } from '@astrojs/starlight/components';
<Card title="Check this out">Interesting content you want to highlight.</Card>Check this out
Interesting content you want to highlight.
Include an icon in a card using the icon attribute set to the name of one of ChaiDocs’s built-in icons.
import { Card } from '@astrojs/starlight/components';
<Card title="Stars" icon="star"> Sirius, Vega, Betelgeuse </Card>Stars
Sirius, Vega, Betelgeuse
Display multiple cards side-by-side when there’s enough space by grouping them using the <CardGrid> component.
See the “Group cards” guide for an example.
<Card> PropsImplementation: Card.astro
The <Card> component accepts the following props:
titlerequired
type: string
The title of the card to display.
icontype: string
A card can include an icon attribute set to the name of one of ChaiDocs’s built-in icons.
To display links to different pages prominently, use the <LinkCard> component.
import { LinkCard } from '@astrojs/starlight/components';Display a link prominently using the <LinkCard> component.
Each <LinkCard> requires a title and an href attribute.
import { LinkCard } from '@astrojs/starlight/components';
<LinkCard title="Authoring Markdown" href="/contribute/starter-kit/page-content/" />Add a short description to a link card using the description attribute.
import { LinkCard } from '@astrojs/starlight/components';
<LinkCard title="Contribute" href="/contribute/starter-kit/project-structure/" description="Step-by-step guide to start contributing to ChaiDocs."/>Display multiple link cards side-by-side when there’s enough space by grouping them using the <CardGrid> component.
See the “Group link cards” guide for an example.
<LinkCard> PropsImplementation: LinkCard.astro
The <LinkCard> component accepts the following props, as well as all other <a> element attributes:
titlerequired
type: string
The title of the link card to display.
hrefrequired
type: string
The URL to link to when the card is interacted with.
descriptiontype: string
An optional description to display below the title.
To wrap multiple <Card> or <LinkCard> components in a grid, use the<CardGrid> component.
Stars
Sirius, Vega, Betelgeuse
Moons
Io, Europa, Ganymede
import { CardGrid } from '@astrojs/starlight/components';Display multiple <Card> components side-by-side when there’s enough space by grouping them using the <CardGrid> component.
import { Card, CardGrid } from '@astrojs/starlight/components';
<CardGrid> <Card title="Check this out" icon="open-book"> Interesting content you want to highlight. </Card> <Card title="Other feature" icon="information"> More information you want to share. </Card></CardGrid>Check this out
Interesting content you want to highlight.
Other feature
More information you want to share.
Display multiple <LinkCard> components side-by-side when there’s enough space by grouping them using the <CardGrid> component.
import { LinkCard, CardGrid } from '@astrojs/starlight/components';
<CardGrid> <LinkCard title="Authoring Markdown" href="/contribute/starter-kit/page-content/" /> <LinkCard title="Components" href="/contribute/starter-kit/components/" /></CardGrid>Shift the second column of the grid vertically to add visual interest by adding the stagger attribute to the <CardGrid> component.
This attribute is useful on your home page to display your project’s key features.
import { Card, CardGrid } from '@astrojs/starlight/components';
<CardGrid stagger> <Card title="Check this out" icon="open-book"> Interesting content you want to highlight. </Card> <Card title="Other feature" icon="information"> More information you want to share. </Card></CardGrid>Check this out
Interesting content you want to highlight.
Other feature
More information you want to share.
<CardGrid> PropsImplementation: CardGrid.astro
The <CardGrid> component accepts the following props:
staggertype: boolean
Defines whether to stagger the cards in the grid or not.
To display optimized images use the <Image> component.

import { Image } from 'astro:assets';Display an image using the <Image> component. The style prop can be used to customize the image appearance. For consistent styling across documentation, we recommend using:
margin: 1.5rem 0 to add top and bottom spacingmargin-inline: auto to center images horizontallyborder-radius: 10px to add rounded cornersThese styles help maintain a uniform look throughout the documentation.
import { Image } from 'astro:assets';import chaicode from '@/assets/branding/brought-to-you-by-white.png';
<Image src={ChaiCode} alt="ChaiCode Banner" width="600px" style={{ 'margin': '1.5rem 0', 'margin-inline': 'auto', 'border-radius': '10px' }}/>
To make an image a link, wrap the <Image> component in an <a> element and provide the href attribute.
import { Image } from 'astro:assets';import udemy from '@/assets/branding/udemy.jpeg';
<a href="https://www.udemy.com/course/web-dev-master/"> <Image src={udemy} alt="Udemy Banner" width="600px" style={{ 'margin': '1.5rem 0', 'margin-inline': 'auto', 'border-radius': '10px' }} /></a><Image> PropsImplementation: Image.astro
The <Image /> component accepts all properties accepted by the HTML <img> tag in addition to the properties described below:
Type: ImageMetadata | string | Promise<{ default: ImageMetadata }>
The format of the src value of your image file depends on where your image file is located:
import { Image } from 'astro:assets';import myImportedImage from '../assets/my-local-image.png';
<Image src={myImportedImage} alt="descriptive text" />Images in the public/ folder - use the image’s file path relative to the public folder:
import { Image } from 'astro:assets';
<Image src="/images/my-public-image.png" alt="descriptive text" width="200" height="150"/>Remote images - use the image’s full URL as the property value:
import { Image } from 'astro:assets';
<Image src="" alt="descriptive text" width="200" height="150"/>Type: string
Use the required alt attribute to provide a string of [descriptive alt text]( for images.
If an image is merely decorative (i.e. doesn’t contribute to the understanding of the page), set alt="" so that screen readers and other assistive technologies know to ignore the image.
public/)Type: number | undefined
These properties define the dimensions to use for the image.
When using images in their original aspect ratio, width and height are optional. These dimensions can be automatically inferred from image files located in src/. For remote images, add the inferSize attribute set to true on the <Image />.
However, both of these properties are required for images stored in your public/ folder as ChaiDocs is unable to analyze these files.
Type: ImageQuality | undefined
quality is an optional property that can either be:
low, mid, high, max) that is automatically normalized between formats.0 to 100 (interpreted differently between formats).Type: boolean
Allows you to set the original width and height of a remote image automatically.
By default, this value is set to false and you must manually specify both dimensions for your remote image.
Add inferSize to the <Image /> component to infer these values from the image content when fetched. This is helpful if you don’t know the dimensions of the remote image, or if they might change:
import { Image } from 'astro:assets';import cat from '@/assets/cat.png';
<Image src={cat} inferSize alt="A cat sleeping in the sun." />To display secondary information alongside a page’s main content, use the <Aside> component.
import { Aside } from '@astrojs/starlight/components';Display an aside (also known as “admonitions” or “callouts”) using the <Aside> component.
An <Aside> can have an optional type attribute, which controls the aside’s color, icon, and default title.
import { Aside } from '@astrojs/starlight/components';
<Aside>Some content in an aside.</Aside>
<Aside type="caution">Some cautionary content.</Aside>
<Aside type="tip">Other content is also supported in asides.
```js// A code snippet, for example.```</Aside>
<Aside type="danger">Do not give your password to anyone.</Aside>ChaiDocs also provides a custom syntax for rendering asides in Markdown and MDX as an alternative to the <Aside> component.
See the “Authoring Content” guide for details of the custom syntax.
Override the default aside titles by using the title attribute.
import { Aside } from '@astrojs/starlight/components';
<Aside type="caution" title="Watch out!"> A warning aside *with* a custom title.</Aside><Aside> PropsImplementation: Aside.astro
The <Aside> component accepts the following props:
typetype: 'note' | 'tip' | 'caution' | 'danger'
default: 'note'
The type of aside to display:
note asides (the default) are blue and display an information icon.tip asides are purple and display a rocket icon.caution asides are yellow and display a triangular warning icon.danger asides are red and display an octagonal warning icon.titletype: string
The title of the aside to display.
If title is not set, the default title for the current aside type will be used.
To display small pieces of information, such as a status or category, use the <Badge> component.
import { Badge } from '@astrojs/starlight/components';Display a badge using the <Badge> component and pass the content you want to display to the text attribute of the <Badge> component.
By default, the badge will use the theme accent color of your site.
To use a built-in badge color, set the variant attribute to one of the supported values.
import { Badge } from '@astrojs/starlight/components';
- <Badge text="Note" variant="note" />- <Badge text="Success" variant="success" />- <Badge text="Tip" variant="tip" />- <Badge text="Caution" variant="caution" />- <Badge text="Danger" variant="danger" />Use the size attribute to control the size of the badge text.
import { Badge } from '@astrojs/starlight/components';
- <Badge text="New" size="small" />- <Badge text="New and improved" size="medium" />- <Badge text="New, improved, and bigger" size="large" />Customize badges by using any other <span> attributes such as class or style with custom CSS.
import { Badge } from '@astrojs/starlight/components';
<Badge text="Custom" variant="success" style={{ fontStyle: 'italic' }} /><Badge> PropsImplementation: Badge.astro
The <Badge> component accepts the following props and also any other <span> attributes:
textrequired
type: string
The text content to display in the badge.
varianttype: 'note' | 'danger' | 'success' | 'caution' | 'tip' | 'default'
default: 'default'
The badge color variant to use: note (blue), tip (purple), danger (red), caution (orange), success (green), or default (theme accent color).
sizetype: 'small' | 'medium' | 'large'
Defines the size of the badge to display.
To display the structure of a directory with file icons and collapsible sub-directories, use the <FileTree> component.
import { FileTree } from '@astrojs/starlight/components';Display a file tree with file icons and collapsible sub-directories using the <FileTree> component.
Specify the structure of your files and directories with an unordered Markdown list inside <FileTree>.
Create a sub-directory using a nested list or add a / to the end of a list item to render it as a directory without specific content.
import { FileTree } from '@astrojs/starlight/components';
<FileTree>
- astro.config.mjs- package.json- src - components - Header.astro - Title.astro - pages/
</FileTree>Make a file or directory stand out by making its name bold, e.g. **README.md**.
import { FileTree } from '@astrojs/starlight/components';
<FileTree>
- src - components - **Header.astro** - Title.astro
</FileTree>Add a comment to a file or directory by adding more text after the name. Inline Markdown formatting such as bold and italics is supported in comments.
import { FileTree } from '@astrojs/starlight/components';
<FileTree>
- src - components - Header.astro an **important** file - Title.astro
</FileTree>Add placeholder files and directories by using either ... or … as the name.
This can be useful to indicate to a reader that a folder is expected to contain more items without specifying them all explicitly.
import { FileTree } from '@astrojs/starlight/components';
<FileTree>
- src - components - Header.astro - …
</FileTree><FileTree> PropsImplementation: FileTree.astro
The <FileTree> component does not accept any props.
To display icons from ChaiDocs’s built-in icon set, use the <Icon> component.
import { Icon } from '@astrojs/starlight/components';Display an icon using the <Icon> component.
An icon requires a name set to one of ChaiDocs’s built-in icons and can optionally include a label to provide context for screen readers.
import { Icon } from '@astrojs/starlight/components';
<Icon name="star" /><Icon name="github" label="Github logo" />The size and color attributes can be used to adjust the icon’s appearance using CSS units and color values.
The class attribute can be used to add custom CSS classes to the icon.
import { Icon } from '@astrojs/starlight/components';
<Icon name="star" color="goldenrod" size="2rem" /><Icon name="rocket" color="var(--sl-color-text-accent)" /><Icon> PropsImplementation: Icon.astro
The <Icon> component accepts the following props:
namerequired
type: StarlightIcon
The name of the icon to display set to one of ChaiDocs’s built-in icons.
labeltype: string
An optional label to provide context for assistive technologies, such as screen readers.
When label is not set, the icon will be completely hidden from assistive technologies.
In this case, make sure the context is still understandable without the icon.
For example, a link containing only the icon must include the label attribute in order to be accessible, but if a link contains text and the icon is purely decorative, omitting the label may make sense.
sizetype: string
The size of the icon using CSS units.
colortype: string
The color of the icon using a CSS color value.
classtype: string
Custom CSS classes to add to the icon.
StarlightIcon typeUse the StarlightIcon TypeScript type to reference the names of ChaiDocs’s built-in icons.
import type { StarlightIcon } from '@astrojs/starlight/types';
const getIconLabel = (icon: StarlightIcon) => { // …}A list of all available icons is shown below with their associated names. Click an icon to copy its name to your clipboard.
To display visually distinct call-to-action links, use the <LinkButton> component.
import { LinkButton } from '@astrojs/starlight/components';Use the <LinkButton> component to display a visually distinct call-to-action link.
A link button is useful for directing users to the most relevant or actionable content and is often used on landing pages.
A <LinkButton> requires an href attribute.
Optionally, customize the appearance of the link button using the variant attribute, which can be set to primary (the default), secondary, or minimal.
import { LinkButton } from '@astrojs/starlight/components';
<LinkButton href="/contribute/guide">Contribute</LinkButton><LinkButton href="/tracks" variant="secondary"> Explore Tracks</LinkButton><LinkButton href="https://courses.chaicode.com" variant="minimal"> Watch Tutorials</LinkButton>Include an icon in a link button using the icon attribute set to the name of one of ChaiDocs’s built-in icons.
The iconPlacement attribute can be used to place the icon before the text by setting it to start (defaults to end).
import { LinkButton } from '@astrojs/starlight/components';
<LinkButton href="https://chaicode.com" variant="secondary" icon="external" iconPlacement="start"> Related: ChaiCode</LinkButton><LinkButton> PropsImplementation: LinkButton.astro
The <LinkButton> component accepts the following props and also any other <a> attributes:
hrefrequired
type: string
The URL that the link button points to.
varianttype: 'primary' | 'secondary' | 'minimal'
default: 'primary'
The appearance of the link button.
Set to primary for a prominent call-to-action link using the theme’s accent color, secondary for a less prominent link, or minimal for a link with minimal styling.
icontype: string
A link button can include an icon attribute set to the name of one of ChaiDocs’s built-in icons.
iconPlacementtype: 'start' | 'end'
default: 'end'
Determines the placement of the icon in relation to the link button text.
To style a numbered list of tasks to create step-by-step guides, use the <Steps> component.
Create project
Run the init command to create a new Next.js project or to setup an existing one:
Choose between a Next.js project or a Monorepo.
Add components
You can now start adding components to your project.
The command above will add the Button component to your project. You can then import it like this:
import { Button } from "@/components/ui/button"
export default function Home() { return ( <div> <Button>Click me</Button> </div> )}import { Steps } from '@astrojs/starlight/components';Use the <Steps> component to style numbered lists of tasks.
This is useful for more complex step-by-step guides where each step needs to be clearly highlighted.
Wrap <Steps> around a standard Markdown ordered list.
All the usual Markdown syntax is applicable inside <Steps>.
import { Steps } from '@astrojs/starlight/components';
<Steps>1. Import the component into your MDX file: ```js import { Steps } from '@astrojs/starlight/components'; ```
2. Wrap `<Steps>` around your ordered list items.</Steps>Import the component into your MDX file:
import { Steps } from '@astrojs/starlight/components';Wrap <Steps> around your ordered list items.
<Steps> PropsImplementation: Steps.astro
The <Steps> component does not accept any props.
The <Code> component renders syntax highlighted code.
It is useful when using a Markdown code block is not possible, for example, to render data coming from external sources like files, databases, or APIs.
## Welcome
Hello from **space**!import { Code } from '@astrojs/starlight/components';Use the <Code> component to render syntax highlighted code, for example when displaying code fetched from external sources.
See the Expressive Code “Code Component” docs for full details on how to use the <Code> component and the list of available props.
import { Code } from '@astrojs/starlight/components';
export const exampleCode = `console.log('This could come from a file or CMS!');`;export const fileName = 'example.js';export const highlights = ['file', 'CMS'];
<Code code={exampleCode} lang="js" title={fileName} mark={highlights} />console.log('This could come from a file or CMS!');In MDX files and Astro components, use Vite’s ?raw import suffix to import any code file as a string.
You can then pass this imported string to the <Code> component to include it on your page.
import { Code } from '@astrojs/starlight/components';import importedCode from '/tsconfig.json?raw';
<Code code={importedCode} lang="json" title="tsconfig.json" />{ "extends": "astro/tsconfigs/strict", "include": [".astro/types.d.ts", "**/*"], "exclude": ["dist"], "compilerOptions": { "baseUrl": ".", "paths": { "@/*": ["./src/*"] } }}<Code> PropsImplementation: Code.astro
The <Code> component accepts all the props documented in the Expressive Code “Code Component” docs.
To create a tabbed interface use the <Tabs> and <TabItem> components.
Tabs are useful for grouping equivalent information where a user only needs to see one of several options.
import { Tabs, TabItem } from '@astrojs/starlight/components';Display a tabbed interface using the <Tabs> and <TabItem> components.
Each <TabItem> must have a label to display to users.
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="Brute Force"> Try all subarrays with nested loops, calculating their sums and tracking the maximum.
O(n²) time | O(1) space </TabItem> <TabItem label="Kadane's Algorithm"> Use dynamic programming to track current and max sums efficiently as you iterate.
O(n) time | O(1) space </TabItem></Tabs>Try all subarrays with nested loops, calculating their sums and tracking the maximum.
O(n²) time | O(1) space
Use dynamic programming to track current and max sums efficiently as you iterate.
O(n) time | O(1) space
Keep multiple tab groups synchronized by adding the syncKey attribute.
All <Tabs> on a page with the same syncKey value will display the same active label.
This allows your reader to choose once (e.g. their operating system or package manager), and see their choice persisted across page navigation.
To synchronize related tabs, add an identical syncKey property to each <Tabs> component and ensure that they all use the same <TabItem> labels:
import { Tabs, TabItem } from '@astrojs/starlight/components';
_Some stars:_
<Tabs syncKey="constellations"> <TabItem label="Orion">Bellatrix, Rigel, Betelgeuse</TabItem> <TabItem label="Gemini">Pollux, Castor A, Castor B</TabItem></Tabs>
_Some exoplanets:_
<Tabs syncKey="constellations"> <TabItem label="Orion">HD 34445 b, Gliese 179 b, Wasp-82 b</TabItem> <TabItem label="Gemini">Pollux b, HAT-P-24b, HD 50554 b</TabItem></Tabs>Include an icon in a tab item using the icon attribute set to the name of one of ChaiDocs’s built-in icons to display an icon next to the label.
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="Stars" icon="star"> Sirius, Vega, Betelgeuse </TabItem> <TabItem label="Moons" icon="moon"> Io, Europa, Ganymede </TabItem></Tabs><Tabs> PropsImplementation: Tabs.astro
The <Tabs> component groups multiple <TabItem> components together and accepts the following props:
syncKeytype: string
A key used to keep multiple tab groups synchronized across multiple pages.
<TabItem> PropsImplementation: TabItem.astro
A set of tabs is composed of tab items, each with the following props:
labelrequired
type: string
A tab item must include a label attribute set to the text that will be displayed in the tab.
icontype: string
Each tab item can include an icon attribute set to the name of one of ChaiCode’s built-in icons to display an icon next to the label.
Displays a list of code blocks with tabs.
import { CodeTabItem, CodeTabs } from '@/components/code'Display a tabbed interface using the <CodeTabs> and <CodeTabItem> components. Each <CodeTabItem> must have a label to display to users.
import { CodeTabs, CodeTabItem } from '@/components/code'
<CodeTabs><CodeTabItem label="Brute Force" lang="ts" code={`const maxSubarraySumBruteForce = (arr: number[]): number => { let maxSum = -Infinity;
for (let i = 0; i < arr.length; i++) { let currentSum = 0;
for (let j = i; j < arr.length; j++) { currentSum += arr[j]; maxSum = Math.max(maxSum, currentSum); } }
return maxSum;}`}/>
<CodeTabItem label="Kadane's Algorithm" lang="ts" code={`const maxSubarraySumKadane = (arr: number[]): number => { let currentSum = arr[0]; let maxSum = arr[0];
for (let i = 1; i < arr.length; i++) { currentSum = Math.max(arr[i], currentSum + arr[i]); maxSum = Math.max(maxSum, currentSum); }
return maxSum;}`}/></CodeTabs>const maxSubarraySumBruteForce = (arr: number[]): number => { let maxSum = -Infinity;
for (let i = 0; i < arr.length; i++) { let currentSum = 0;
for (let j = i; j < arr.length; j++) { currentSum += arr[j]; maxSum = Math.max(maxSum, currentSum); } }
return maxSum;}const maxSubarraySumKadane = (arr: number[]): number => { let currentSum = arr[0]; let maxSum = arr[0];
for (let i = 1; i < arr.length; i++) { currentSum = Math.max(arr[i], currentSum + arr[i]); maxSum = Math.max(maxSum, currentSum); }
return maxSum;}Keep multiple CodeTab groups synchronized by adding the syncKey attribute.
All <CodeTabs> on a page with the same syncKey value will display the same active label. This allows your readers to choose once (e.g., their preferred programming language) and see their choice persisted across the page and during navigation.
To synchronize related tabs, add an identical syncKey property to each <CodeTabs> component and ensure they all use the same <CodeTabItem> labels:
import { CodeTabs, CodeTabItem } from '@components/code';
_String Manipulation Examples:_
<CodeTabs syncKey="programming-language">
<CodeTabItem label="JavaScript" lang="js" code={`const toUpper = (text) => { return text.toUpperCase(); }`}/>
<CodeTabItem label="Python" lang="python" code={`# Convert to uppercase def to_upper(text): return text.upper()`}/>
</CodeTabs>
_Array/List Operations:_
<CodeTabs syncKey="programming-language">
<CodeTabItem label="JavaScript" lang="js" code={`const sumArray = (arr) => { return arr.reduce((sum, num) => sum + num, 0); }`}/>
<CodeTabItem label="Python" lang="python" code={`# Sum a list def sum_list(lst): return sum(lst)`}/>
</CodeTabs>String Manipulation Examples:
const toUpper = (text) => { return text.toUpperCase();}# Convert to uppercasedef to_upper(text): return text.upper()Array/List Operations:
const sumArray = (arr) => { return arr.reduce((sum, num) => sum + num, 0);}# Sum a listdef sum_list(lst): return sum(lst)<CodeTabs> PropsImplementation: CodeTabs.astro
The <CodeTabs> component groups multiple <CodeTabItem> components together and accepts the following props:
syncKeytype: string
A key used to keep multiple tab groups synchronized across multiple pages.
<CodeTabItem> PropsImplementation: CodeTabItem.astro
The <CodeTabItem> component accepts the following props, as well as all other <Code> component props:
labelrequired
type: string
A CodeTab item must include a label attribute set to the text that will be displayed in the tab.
Now a days we have so many package managers to choose from. This component helps you to display a list of commands for different package managers.
import { CodePackageManagers } from '@/components/code'Displays a list of commands for different package managers using <CodePackageManagers> component. <CodePackageManagers> must have a packages attribute set to the name of the package(s) to install.
import { CodePackageManagers } from '@/components/code'
<CodePackageManagers packages="express"/>You can install the package as a dev dependency by setting the dev attribute to true.
import { CodePackageManagers } from '@/components/code'<CodePackageManagers packages="typescript" dev={true}/>You can execute a command by setting the commandType attribute to "execute" and passing the args attribute to the command.
import { CodePackageManagers } from '@/components/code'
<CodePackageManagers packages="shadcn@latest" commandType="execute" args="init"/>You can customize the package managers to use by setting the packageManagers attribute to an array of package manager names.
import { CodePackageManagers } from '@/components/code'
<CodePackageManagers packageManagers={['pnpm', 'bun', 'deno']} packages="pino"/>You can create a custom command by setting the commandType attribute to "custom" and passing the args attribute.
import { CodePackageManagers } from '@/components/code'<CodePackageManagers packageManagers={['bun', 'pnpm']} commandType="custom" args="create hono@latest"/><CodePackageManagers> PropsImplementation: CodePackageManagers.astro
The <CodePackageManagers> component accepts the following props:
packageManagerstype: 'pnpm' | 'npm' | 'yarn' | 'bun' | 'deno'
default: ['bun', 'pnpm', 'npm', 'yarn']
The package managers to use.
packagestype: string
The packages to install. If you want to install multiple packages, you can pass a space-separated string.
devtype: boolean
default: false
Whether to install the packages as dev dependencies.
commandTypetype: 'install' | 'execute' | 'custom'
default: 'install'
The type of command to generate. Use 'install' for package installation commands, 'execute' for running commands and 'custom' for custom commands.
argstype: string
The arguments to pass to the command. This prop is only used when commandType is set to 'execute' or 'custom'.
The <YouTube> component generates an embed using the lite-youtube-embed custom element that will load YouTube’s <iframe> only when a user clicks play.
YouTube embeds will always require some JavaScript, but this is one of the most minimal and performant ways to embed a YouTube video.
import { YouTube } from 'astro-embed'Displays a YouTube video using the <YouTube> component. The <YouTube> component must have an id attribute set to the video ID or URL.
import { YouTube } from 'astro-embed'
<YouTube id="sn4cDCq52h8" posterQuality="max"/>You can provide an alternative poster image by passing in a URL to the poster prop.
For example, this is the same video as above but with a custom poster image:
import { YouTube } from 'astro-embed'
<YouTube id="sn4cDCq52h8" poster="https://images.pexels.com/photos/18681382/pexels-photo-18681382/free-photo-of-coding.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2"/>When using the default YouTube poster image, set the posterQuality to change the size of the placeholder image. This can be useful if displaying the embed at very large or very small sizes.
There are four possible values:
| posterQuality | resolution |
|---|---|
| low | 120px |
| default | 480px |
| high | 640px |
| max | 1280px |
We recommend using max for the best quality. For example :
import { YouTube } from 'astro-embed'
<YouTube id="2JroEREiBLw" posterQuality="max"/>You can pass in a params prop to set the YouTube player parameters. This looks like a series of URL search params.
For example, the following params value sets the start and end times of the video playback:
import { YouTube } from 'astro-embed'
<YouTube id="6A52M3b7tl8" params="start=245&end=303" posterQuality="max"/>You can provide a custom title for the video by passing in a title prop.
import { YouTube } from 'astro-embed'
<YouTube id="KRDwp6J_LTQ" title="My Favorite Video" posterQuality="max"/><YouTube> PropsImplementation: YouTube.astro
The <YouTube> component accepts the following props:
idtype: string
The YouTube video ID or URL.
postertype: string
The URL of the poster image to use.
posterQualitytype: 'low' | 'default' | 'high' | 'max'
default: 'default'
The quality of the poster image.
paramstype: string
The URL search params to pass to the YouTube player.
titletype: string
The title of the video.
The <LinkPreview> component embeds the Open Graph media and metadata for a URL in your page.

import { LinkPreview } from 'astro-embed'Displays a link preview using the <LinkPreview> component. The <LinkPreview> component must have an id attribute set to the URL of the page to embed.
import { LinkPreview } from 'astro-embed'
<LinkPreview id="https://leerob.com/"/>
If a URL’s tags include og:video metadata, <LinkPreview> will render a video player instead of an image.
import { LinkPreview } from 'astro-embed'<LinkPreview id="https://giphy.com/gifs/bypriyashah-india-chai-3ohzAh7PHabMBiBzDG"/>If a URL’s image or video is unwanted, add hideMedia as a prop.
import { LinkPreview } from 'astro-embed'
<LinkPreview hideMedia id="https://hitesh.ai"/>The available Open Graph metadata varies from site to site. If a site doesn’t provide og:image metadata, no image will be displayed, only the page title and description.
If no title is detected or the metadata collection step fails, <LinkPreview> will display only the original link URL.
<LinkPreview> PropsImplementation: LinkPreview.astro
The <LinkPreview> component accepts the following props:
idtype: string
The URL of the page to embed.
hideMediatype: boolean
default: false
To hide the media.
All of our courses are available on chaicode.com. Feel free to check them out.