Skip to content

FormSkeleton

The shape of a form while its values load: labels and fields as skeletons, in one or two columns, with the buttons at the end.

import { FormSkeleton } from '@sypnia/ui/react'

On this page
  1. Loading a connection
  2. When to use it
  3. For everyone
  4. Props

Loading a connection

Press «Load again» to see it.

Code
import { useState } from 'react';
import { Button, Field, FormGrid, FormSkeleton, Input } from '@sypnia/ui/react';

// The shape of the form while its values load. Press the button to load it again.
export default function Loading() {
  const [loading, setLoading] = useState(true);
  const reload = () => { setLoading(true); setTimeout(() => setLoading(false), 1600); };
  return (
    <div className="sy-stack">
      <Button size="sm" variant="secondary" onClick={reload} icon="refresh">Load again</Button>
      {loading ? <FormSkeleton fields={4} columns={2} /> : (
        <FormGrid>
          <Field label="Host"><Input machine defaultValue="db.northwind.io" /></Field>
          <Field label="Port"><Input machine defaultValue="5432" /></Field>
          <Field label="User"><Input machine defaultValue="reporting" /></Field>
          <Field label="Database"><Input machine defaultValue="shop" /></Field>
        </FormGrid>
      )}
    </div>
  );
}

When to use it

Use it when

  • A form that edits something loaded from the server.
  • Match the real form: same number of fields and columns, so nothing jumps when it arrives.

Do not use it when

  • New forms that start empty: show them at once.
  • Long waits: say what is happening in words.

For everyone

  • It is hidden from screen readers; the page that loads should say it is busy (aria-busy).

Props

FormSkeletonTypeDefault
actions boolean true
columns 1 | 2 1
fields number 4
  1. Loading a connection
  2. When to use it
  3. For everyone
  4. Props

    Search pages, sections and terms