### Install VSCode Elements
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/guides/getting-started.mdx
Installs the VSCode Elements library using npm. This is the primary method for adding the library to your project.
```bash
npm i @vscode-elements/elements
```
--------------------------------
### Include Bundled VSCode Elements
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/guides/getting-started.mdx
Includes the bundled version of VSCode Elements directly in your HTML file using a script tag. This is a simple way to get started.
```html
```
--------------------------------
### Set VSCode Element Attribute via HTML
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/guides/getting-started.mdx
Shows how to configure a VSCode Element using HTML attributes, like setting the 'variant' for a vscode-badge.
```html
```
--------------------------------
### VSCode Element Default Slot Usage
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/guides/getting-started.mdx
Shows the basic usage of a VSCode Element, like vscode-button, with content placed in the default slot.
```html
Click here
```
--------------------------------
### Set VSCode Element Property via JavaScript
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/guides/getting-started.mdx
Demonstrates how to configure a VSCode Element's property, such as setting the 'variant' of a vscode-badge, using JavaScript.
```javascript
const badge = document.querySelector("vscode-badge");
badge.variant = "activity-bar-counter";
```
--------------------------------
### Listen to VSCode Element Events
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/guides/getting-started.mdx
Demonstrates how to add an event listener to a VSCode Element, such as listening for the 'vsc-tabs-select' event on a vscode-tabs component.
```javascript
const tabs = document.querySelector("vscode-tabs");
tabs.addEventListener("vsc-tabs-select", () => {
console.log("A tab has been selected.");
});
```
--------------------------------
### Call VSCode Element Method
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/guides/getting-started.mdx
Illustrates how to invoke a method on a VSCode Element instance, such as calling 'reportValidity()' on a textfield.
```javascript
const textfield = document.querySelector("vscode-textfield");
textfield.reportValidity();
```
--------------------------------
### Basic Form Example
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/guides/working-with-forms.mdx
Demonstrates a simple form submission using VSCode Elements components. This example shows how to create a form with a text input and a submit button, mimicking native HTML form behavior.
```html
```
--------------------------------
### Starlight Project Commands
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/README.md
Lists essential npm commands for managing and running an Astro project with Starlight. These commands cover installation, development, building, and previewing.
```bash
npm install
npm run dev
npm run build
npm run preview
npm run astro ...
npm run astro -- --help
```
--------------------------------
### Basic Textfield Example
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/textfield.mdx
Demonstrates the fundamental usage of the vscode-textfield component with no additional attributes or slots.
```html
```
--------------------------------
### Basic Tabs Example
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/tabs.mdx
Demonstrates the basic usage of the vscode-tabs component with multiple tab headers and panels. Includes a badge for one of the tabs.
```html
Lorem
Lorem ipsum dolor...
Ipsum2
Aliquam malesuada rhoncus nulla...
Dolor
Nulla facilisi. Vivamus...
```
--------------------------------
### Toggleable Toolbar Button Example
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/toolbar-button.mdx
Provides an example of a toggleable vscode-toolbar-button and demonstrates how to handle the 'change' event using JavaScript.
```html
```
```javascript
const el = document.querySelector("#toggle-example");
el.addEventListener("change", () => {
console.log("Checked:", el.checked);
});
```
--------------------------------
### Toolbar Button Basic Example
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/toolbar-button.mdx
Demonstrates the basic usage of the vscode-toolbar-button component with an icon and a label for screen readers.
```html
```
--------------------------------
### Basic Toolbar Button Example
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/toolbar-container.mdx
Demonstrates the basic usage of vscode-toolbar-container and vscode-toolbar-button to create a functional toolbar with labeled buttons.
```html
```
--------------------------------
### Basic Multi Select Example
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/multi-select.mdx
Demonstrates the basic usage of the vscode-multi-select component with options and event handling.
```html
Lorem
Ipsum
Dolor
```
```javascript
const select = document.querySelector("#select-example");
select.addEventListener("change", () => {
console.log(select.value);
});
```
--------------------------------
### Basic Progress Ring Example
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/progress-ring.mdx
Demonstrates the basic usage of the vscode-progress-ring component. This snippet shows the HTML structure required to render a simple progress ring.
```html
```
--------------------------------
### Basic vscode-collapsible Example
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/collapsible.mdx
Demonstrates the basic usage of the vscode-collapsible component, showing how to create collapsible sections that can be open by default or closed.
```html
Open by default
Suspendisse potenti. Maecenas eu egestas metus. Nulla eget placerat mi, et efficitur augue.
```
--------------------------------
### Import Specific VSCode Element Component
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/guides/getting-started.mdx
Imports a specific VSCode Element component, such as vscode-button, for use in your TypeScript project. This allows for more granular control over dependencies.
```typescript
import "@vscode-elements/elements/dist/vscode-button/index.js";
```
--------------------------------
### Customize VSCode Element Appearance with CSS Properties
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/guides/getting-started.mdx
Explains how to customize the appearance of VSCode Elements using CSS custom properties, such as changing the hover background of a vscode-button.
```css
vscode-button {
--vscode-button-hoverBackground: red;
}
```
--------------------------------
### VSCode Element Named Slot Usage
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/guides/getting-started.mdx
Demonstrates using a named slot ('decorations') within a VSCode Element (vscode-collapsible) to place another component (vscode-badge).
```html
99
Suspendisse potenti. Maecenas eu egestas metus. Nulla eget placerat mi, et
efficitur augue.
```
--------------------------------
### Install Webview Playground
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/guides/framework-integrations/react.mdx
Installs the @vscode-elements/webview-playground package as a development dependency for applying VSCode styles during development.
```bash
npm i -D @vscode-elements/webview-playground
```
--------------------------------
### Responsive Form Container Example
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/form-container.mdx
Demonstrates the responsive layout capabilities of the Form Container component.
```astro
```
--------------------------------
### VSCode Element Default View CSS
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/guides/getting-started.mdx
Provides a default, hidden state for VSCode elements using CSS until they are registered. This prevents FOUC (Flash of Unstyled Content).
```css
vscode-buttton:not(:defined) {
display: inline-block;
height: 26px;
visibility: hidden;
width: 100px;
}
```
--------------------------------
### Basic Form Helper Example
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/form-helper.mdx
Demonstrates the basic usage of the vscode-form-helper component, allowing for rich HTML content within the helper text.
```html
Lorem ipsum let dolor = sit amet, consectetur adipiscing
elit. Suspendisse faucibus imperdiet sapien,
a gravida dolor.
Lorem
Ipsum
Dolor
```
--------------------------------
### Basic Checkbox Example
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/checkbox.mdx
Demonstrates a standard checkbox with a label and a pre-checked state. Includes the component usage and its HTML representation.
```astro
import FormControlInfo from "@components/form-control-info.md";
import Demo from "@components/Demo.astro";
import PageSwitcher from "@components/PageSwitcher.astro";
import Imports from "@components/examples/checkbox/Imports.astro";
## Basic example
```html
```
```
--------------------------------
### Install React Wrapper Components
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/guides/framework-integrations/react.mdx
Installs the @vscode-elements/react-elements package for integrating VSCode Elements with React versions 18 and older.
```bash
npm i @vscode-elements/react-elements
```
--------------------------------
### Basic Divider HTML Example
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/divider.mdx
Demonstrates the basic usage of the vscode-divider custom HTML element to create a visual separator.
```html
Praesent ultrices mauris ...
Praesent ultrices mauris ...
```
--------------------------------
### Settings Page Form Group Example
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/form-group.mdx
Shows the 'settings-group' variant of the vscode-form-group, designed to mimic the native settings page appearance with a specific element order.
```html
Lorem ipsum:
Lorem ipsum let dolor = sit amet, consectetur adipiscing
elit. Suspendisse faucibus imperdiet
sapien, a gravida dolor.
```
--------------------------------
### Basic Single Select Example
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/single-select.mdx
Demonstrates the fundamental usage of the vscode-single-select component, including how to add options and handle selection changes. It shows the HTML structure for the select element and JavaScript for event listening.
```html
LoremIpsumDolor
```
```javascript
const select = document.querySelector('#select-example');
select.addEventListener('change', (event) => {
console.log(select.value);
});
```
--------------------------------
### Form Container Imports
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/form-container.mdx
Imports necessary components for the Form Container, including Demo, PageSwitcher, and specific examples for form container functionality.
```astro
import Demo from "@components/Demo.astro";
import PageSwitcher from "@components/PageSwitcher.astro";
import Imports from "@components/examples/form-container/Imports.astro";
import ResponsiveExample from "@components/examples/form-container/ResponsiveExample.astro";
```
--------------------------------
### Split Button Example
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/button-group.mdx
Demonstrates a basic split button using vscode-button-group and vscode-button. The first button acts as the primary action, while the second button with an icon provides secondary actions.
```html
Split Button
```
--------------------------------
### Basic Form Group Example
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/form-group.mdx
Demonstrates the default horizontal layout of the vscode-form-group component, used for organizing form elements.
```html
Lorem ipsum:
Lorem ipsum let dolor = sit amet, consectetur adipiscing
elit. Suspendisse faucibus imperdiet
sapien, a gravida dolor.
```
--------------------------------
### Basic vscode-table Example
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/table.mdx
Demonstrates the basic structure of the vscode-table component with a fixed header and bordered rows. It includes header cells for 'First name', 'Last name', and 'Email', and sample data rows.
```html
First nameLast nameEmailVincenzaLindgrenDelia21@yahoo.comClarkBreitenbergNat_Moore@gmail.comFionaWintheiserAsa30@gmail.com
```
--------------------------------
### Responsive vscode-table Layout
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/table.mdx
Implements a responsive vscode-table that switches to a compact layout on smaller screens. This example uses `responsive` and `breakpoint="400"` attributes, along with `bordered-columns` and `zebra` for styling.
```html
First nameLast nameVincenzaLindgren
...
```
--------------------------------
### vscode-tree with Codicons
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/tree.mdx
Demonstrates the usage of the vscode-tree component with built-in codicons for folder and file representation. This example shows how to structure hierarchical data using vscode-tree-item elements and assign appropriate icons.
```html
vscode-tree
helpers.test.ts
helpers.ts
index.ts
tree-context.ts
vscode-tree.styles.ts
vscode-tree.test.ts
vscode-tree.ts
```
--------------------------------
### Create Starlight Project
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/README.md
Command to create a new Astro project using the Starlight template. This sets up the basic structure for documentation sites.
```bash
npm create astro@latest -- --template starlight
```
--------------------------------
### Starlight Project Structure
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/README.md
Illustrates the typical directory and file structure of an Astro project integrated with Starlight. It highlights where documentation files, assets, and configuration reside.
```markdown
.\n├── public/\n├── src/\n│ ├── assets/\n│ ├── content/\n│ │ ├── docs/\n│ │ └── config.ts\n│ └── env.d.ts\n├── astro.config.mjs\n├── package.json\n└── tsconfig.json
```
--------------------------------
### Split Layout - Fixed Pane
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/split-layout.mdx
Shows how to fix one of the panes in a vscode-split-layout using the `fixed-pane` attribute. This example fixes the 'start' pane, preventing it from being resized.
```html
Left
Right
```
```css
vscode-split-layout {
height: 250px;
width: 100%;
}
vscode-split-layout [slot="start"],
vscode-split-layout [slot="end"] {
align-items: center;
display: flex;
justify-content: center;
overflow: hidden;
}
```
--------------------------------
### Import VSCode Element Custom Event Type
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/guides/getting-started.mdx
Imports the TypeScript type for a custom event dispatched by a VSCode Element, like VscTabsSelectEvent for vscode-tabs.
```typescript
import type { VscTabsSelectEvent } from "@vscode-elements/elements/dist/vscode-tabs/vscode-tabs";
```
--------------------------------
### Basic vscode-icon Usage
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/icon.mdx
Demonstrates the basic usage of the vscode-icon component with different size attributes. It also includes instructions on how to include the codicon stylesheet.
```html
```
--------------------------------
### Horizontal Radio Example
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/radio.mdx
Demonstrates the default horizontal layout of the Radio component within a Radio Group.
```html
```
--------------------------------
### Vertical Form Group Example
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/form-group.mdx
Illustrates the vertical layout option for the vscode-form-group component, arranging elements one below the other.
```html
Lorem ipsum:
Lorem ipsum let dolor = sit amet, consectetur adipiscing
elit. Suspendisse faucibus imperdiet
sapien, a gravida dolor.
```
--------------------------------
### Basic Button
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/button.mdx
Demonstrates the fundamental usage of the vscode-button component to create a standard button.
```html
Button
```
--------------------------------
### Vertical Radio Example
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/radio.mdx
Shows how to configure the Radio component for a vertical layout using the 'variant' attribute on the Radio Group.
```html
```
--------------------------------
### Basic Textarea Usage
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/textarea.mdx
Demonstrates the basic implementation of the vscode-textarea component.
```html
```
--------------------------------
### Scrollable Component Example
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/collapsible.mdx
Demonstrates the usage of vscode-collapsible and vscode-scrollable components to display a tree structure within a fixed height. Includes icons with event listeners.
```html
File saved
File saved
...
```
```css
.collapsible.complex-example vscode-scrollable {
height: 200px;
}
```
```javascript
document.getElementById("pin-icon").addEventListener("click", (ev) => {
// Prevent collapsing of the component:
ev.stopPropagation();
});
document.getElementById("refresh-icon").addEventListener("click", (ev) => {
// Prevent collapsing of the component:
ev.stopPropagation();
});
document.getElementById("filter-icon").addEventListener("click", (ev) => {
// Prevent collapsing of the component:
ev.stopPropagation();
});
```
--------------------------------
### Toggle Switch Checkbox
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/checkbox.mdx
Demonstrates the checkbox component used as a toggle switch for enabling/disabling functions. Explains the difference from standard checkboxes and provides component/HTML examples.
```astro
import Demo from "@components/Demo.astro";
Toggle switch
```html "toggle"
Toggle switch
```
```
--------------------------------
### Split Layout - Basic Vertical
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/split-layout.mdx
Demonstrates the default vertical splitting behavior of the vscode-split-layout component. It divides the available space into a 'start' and 'end' pane.
```html
Left
Right
```
```css
vscode-split-layout {
height: 200px;
width: 500px;
}
[slot="start"],
[slot="end"] {
align-items: center;
display: flex;
justify-content: center;
overflow: hidden;
}
```
--------------------------------
### VS Code Icon Component Usage
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/icon.mdx
Demonstrates the usage of the `` component to display different icons. The `name` attribute specifies the icon to render, and the `title` attribute provides accessibility and a tooltip.
```html
```
--------------------------------
### Basic Tree Structure
Source: https://github.com/vscode-elements/vscode-elements.github.io/blob/main/src/content/docs/components/tree.mdx
Demonstrates the fundamental structure of a vscode-tree component with nested vscode-tree-item elements to create a hierarchical view. This example shows how to define branches and leaves.
```html
Fruits
Citrus Fruits
OrangeLemonGrapefruit
Berries
StrawberryBlueberryRaspberry
Tropical Fruits
MangoPineapplePapaya
Vegetables
Leafy Greens
SpinachLettuceKale
Root Vegetables
CarrotBeetrootRadish
Nightshades
TomatoEggplantBell Pepper
```