Getting started
Add @woodger/antd to a Svelte 5 and TypeScript application.
Installing the package
Run this command from your application directory.
npm install @woodger/antd
Import version from @woodger/antd to read the installed version. Use GetProps, GetProp, and GetRef for component props, an individual prop, and a component ref.
npm updates package.json and package-lock.json. If your application imports Day.js, add dayjs as a direct dependency.
Application selection
| Application | Next step |
|---|---|
| Svelte without server routes | Svelte and Vite |
| Routes, data loading and SSR | SvelteKit |
| Already existing project | Save its configuration, include the package and test the build |
Styles and ConfigProvider
ConfigProvider includes styles and passes theme, size and locale to child components. locale translates the library signatures, but not the text of the application itself. Usually one provider is placed in the root component of the application or layout.
If components are used without a ConfigProvider, import the styles once at the application entry point:
import '@woodger/antd/styles.css';
Import components from @woodger/antd, not from internal src or dist paths. The internal files device is not a consumer API.
First example
Enter a name and click the button. The example uses $state, bind:value and a regular onclick. Open the card source code and transfer it to App.svelte or application page.
First example
Input stores the value via bind:value; Button updates the result of the action.
<script lang="ts">
import { Button, ConfigProvider, Input } from '@woodger/antd';
let name = $state('');
let greeting = $state('');
</script>
<style>
.example {
display: grid;
gap: 12px;
max-width: 320px;
}
.example :global(.ant-btn) { justify-self: start; }
output {
min-height: 22px;
overflow-wrap: anywhere;
}
</style>
<ConfigProvider>
<div class="example">
<label for="getting-started-name">{("Your name")}</label>
<Input id="getting-started-name" bind:value={name} placeholder={("Enter name")} />
<Button type="primary" onclick={() => {
greeting = name.trim()
? ("Hello, " + String((name.trim())) + "!")
: ("Enter a name first.");
}}>{("Show greeting")}</Button>
<output aria-label={("Result of the first example")}>{greeting}</output>
</div>
</ConfigProvider>
Checking connection
Check the first example: the field accepts input, the button updates the result, and if the name is empty, a tooltip is displayed. Then run type check scripts and build your application. The command names belong to its package.json.
With SSR, additionally check the direct request without JavaScript and the subsequent connection of handlers. Changing the theme and size should not reset the entered text. Analysis of connection errors is in FAQ.
Next steps
- Configure the theme and choose design tokens.
- Select locale and direction.
- Disassemble SSR and hydration and styles.
- Explore TypeScript, SSR and API Features.
- Go to components: Each family has working examples with source code, API and limitations.