Skip to content
tcpsystemsui

Theme

Colour scheme
Accent
Density
Radius
Esc

CodeTabs

Language tabs over shared Tabs with readable no-JS panels.

beta

Examples

Install

pnpm
pnpm add @tcpsystems/ui
Install.svelte
<script lang="ts">
	import CodeTabs from '@tcpsystems/ui/foundation/CodeTabs';
	const items = [
		{ id: 'pnpm', label: 'pnpm', code: 'pnpm add @tcpsystems/ui', lang: 'bash' },
		{ id: 'npm', label: 'npm', code: 'npm install @tcpsystems/ui', lang: 'bash' },
		{ id: 'yarn', label: 'yarn', code: 'yarn add @tcpsystems/ui', lang: 'bash' }
	];
</script>

<CodeTabs {items} label="Install command" />

Request

curl
curl https://search.tcp.systems/v1/search \
  -H "Authorization: Bearer $TCP_KEY" \
  -d '{"query":"svelte 5 runes"}'
Request.svelte
<script lang="ts">
	import CodeTabs from '@tcpsystems/ui/foundation/CodeTabs';
	const items = [
		{ id: 'curl', label: 'curl', lang: 'bash', code: 'curl https://search.tcp.systems/v1/search \\\n  -H "Authorization: Bearer $TCP_KEY" \\\n  -d \'{"query":"svelte 5 runes"}\'' },
		{ id: 'ts', label: 'TypeScript', lang: 'ts', code: "const res = await fetch('https://search.tcp.systems/v1/search', {\n  method: 'POST',\n  headers: { Authorization: `Bearer ${key}` },\n  body: JSON.stringify({ query: 'svelte 5 runes' })\n});" },
		{ id: 'go', label: 'Go', lang: 'go', code: 'req, _ := http.NewRequest("POST", url, body)\nreq.Header.Set("Authorization", "Bearer "+key)\nres, err := http.DefaultClient.Do(req)' }
	];
</script>

<CodeTabs {items} label="Search request" />

Config

studio.toml
[server]
listen = ":8080"
log_level = "info"
Config.svelte
<script lang="ts">
	import CodeTabs from '@tcpsystems/ui/foundation/CodeTabs';
	const items = [
		{ id: 'toml', label: 'studio.toml', lang: 'toml', code: '[server]\nlisten = ":8080"\nlog_level = "info"' },
		{ id: 'json', label: 'studio.json', lang: 'json', code: '{\n  "server": {\n    "listen": ":8080",\n    "log_level": "info"\n  }\n}' }
	];
</script>

<CodeTabs {items} label="Config formats" />

Single

Shell
tcp login
tcp whoami
Single.svelte
<script lang="ts">
	import CodeTabs from '@tcpsystems/ui/foundation/CodeTabs';
	const items = [{ id: 'sh', label: 'Shell', lang: 'bash', code: 'tcp login\ntcp whoami' }];
</script>

<CodeTabs {items} label="Sign in" />

API

Import
import CodeTabs from '@tcpsystems/ui/foundation/CodeTabs';
PropTypeDefault
items{ id: string; label: string; code: string; lang?: string; html?: string; current?: boolean }[]none
label?string'Code languages'
HookKind
.tcp-code-tabsRoot class