Tool call
A disclosure for one tool call: its name and status, with its input and output as text.
Example
<focsd-tool-call id="tool-demo" name="search_docs" status="done"></focsd-tool-call>
<script type="module">const tool = document.getElementById('tool-demo');tool.input = { query: 'feed pattern', limit: 2 };tool.output = { hits: 2 };</script>Usage
Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.
<script type="module"> import '@focsd-dev/ai';</script>
<focsd-tool-call name="search_docs" status="done"></focsd-tool-call>import { useEffect, useRef } from 'react';import '@focsd-dev/ai';
export function Example() { const ref = useRef(null); useEffect(() => { const el = ref.current; const handle = (e) => console.log(e.target); el.addEventListener('toggle', handle); return () => el.removeEventListener('toggle', handle); }, []); return <focsd-tool-call ref={ref} name="search_docs" status="done"></focsd-tool-call>;}<script setup>import '@focsd-dev/ai';</script>
<template> <focsd-tool-call @toggle="onChange" name="search_docs" status="done"></focsd-tool-call></template>// Add CUSTOM_ELEMENTS_SCHEMA to the component's schemas, then:import '@focsd-dev/ai';
// template<focsd-tool-call (toggle)="onChange($event)" name="search_docs" status="done"></focsd-tool-call><script> import '@focsd-dev/ai';</script>
<focsd-tool-call ontoggle={(e) => console.log(e.target)} name="search_docs" status="done"></focsd-tool-call>API
Attributes
| Attribute | Property | Type | Default |
|---|---|---|---|
name | name | string | — |
status | status | ToolStatus | running |
open | open | boolean | false |
Events
| Event | Description |
|---|---|
toggle | Fired when it opens or closes. Like <details>, it does not bubble. |
CSS parts
Style the inside of the component with ::part(), for example focsd-tool-call::part(summary).
| Part | Description |
|---|---|
summary | The button that opens and closes it. |
status | The status icon and word. |
input | The input (`pre`). |
output | The output (`pre`), when there is one. |
Accessibility
- A disclosure button named "search_docs, done": the status is a word as well as an icon (running, done or failed), never color alone.
- Input and output are shown in
preblocks as text (JSON.stringify, never HTML), so they cannot inject markup. A block that scrolls is a region named "Input" or "Output" in the tab order; one that fits adds no tab stop. - It fires the
toggleevent when it opens or closes, like<details>, and does not bubble. - The running ring does not spin under reduced motion.
Keyboard
| Key | Action |
|---|---|
| Enter / Space | Open or close the input and output |
Ask the docs
Hi, what are you building?
Ask about any component, theming, forms or frameworks. I answer with the right component, a snippet and a link to its docs.