Lynx ui dialog

From lynx-family/lynx-ui · View interactive version

Lynx ui dialog is an AI agent skill from the GitHub repository lynx-family/lynx-ui. `Dialog` is a dialog component, used to display important information or require user interaction, interrupting the current workflow. `lynx-ui-dialog` is a composite component built on `primitives`, o

How to use this skill

Skill file

lynx-ui-dialog SKILL

Dialog is a dialog component, used to display important information or require user interaction, interrupting the current workflow. lynx-ui-dialog is a composite component built on primitives, offering high flexibility and customizability.

1. Core Capabilities

2. AI Coding Guide

Minimal Usable Example

Uncontrolled Mode
import {
  DialogRoot,
  DialogView,
  DialogBackdrop,
  DialogContent,
  DialogTrigger,
  DialogClose,
} from '@lynx-js/lynx-ui'

function UncontrolledDialog() {
  return (
    <DialogRoot>
      <DialogTrigger>
        <button>Open Dialog</button>
      </DialogTrigger>
      <DialogView>
        <DialogBackdrop />
        <DialogContent>
          <text>This is a dialog.</text>
          <DialogClose>
            <button>Close</button>
          </DialogClose>
        </DialogContent>
      </DialogView>
    </DialogRoot>
  )
}

Recommended Prompt Formula

Mode (Controlled/Uncontrolled) + Content and Structure + Interaction Logic (e.g., closing, confirmation)

Example Prompt:

<!-- Removed pitfalls; converted into FAQ to match FeedList structure -->

3. Use Cases & Best Practices

Uncontrolled Dialog

Simple to use, with the component managing its own state.

import { DialogRoot, ... } from '@lynx-js/lynx-ui';

function UncontrolledDialogExample() {
  return (
    <DialogRoot>
      <DialogTrigger>Open</DialogTrigger>
      <DialogView>
        <DialogBackdrop clickToClose />
        <DialogContent>
          {/* ... Dialog Content ... */}
          <DialogClose>Close</DialogClose>
        </DialogContent>
      </DialogView>
    </DialogRoot>
  );
}

Example Path: apps/examples/src/Dialog/Uncontrolled/index.tsx

Controlled Confirmation Dialog

Suitable for scenarios that require interaction with external business logic, such as confirmation boxes.

import { useState } from '@lynx-js/react';
import { DialogRoot, ... } from '@lynx-js/lynx-ui';

function ControlledConfirmDialog() {
  const [isOpen, setIsOpen] = useState(false);

  const handleConfirm = () => {
    // business logic
    setIsOpen(false);
  };

  return (
    <view>
      <button onClick={() => setIsOpen(true)}>Delete</button>
      <DialogRoot show={isOpen} onShowChange={setIsOpen}>
        <DialogView>
          <DialogBackdrop />
          <DialogContent>
            <text>Are you sure?</text>
            <DialogClose>Cancel</DialogClose>
            <button onClick={handleConfirm}>Confirm</button>
          </DialogContent>
        </DialogView>
      </DialogRoot>
    </view>
  );
}

Example Path: apps/examples/src/Dialog/Controlled/index.tsx

4. FAQ

Q: Why doesn’t the dialog open/close when I set show?

A: In controlled mode, DialogRoot does not mutate state internally. Provide onShowChange and update the external show state in that callback.

Q: The dialog appears but is covered by other elements. How do I make it visible?

A: Use container and overlayLevel on DialogView to render into a higher native overlay layer, for example container="window" overlayLevel={2}.

Q: Can I use show and defaultShow at the same time?

A: No. Choose one mode only. Mixing controlled and uncontrolled props will cause incorrect behavior.

Q: How should I set z-index for the Dialog to avoid stacking issues?

A: Due to DialogView defaulting to position: fixed, and because of stacking context limitations, if you need to set z-index for the Dialog, you should set it on the DialogView layer, at the same level as position: fixed. Otherwise, layer stacking issues may occur.

<DialogView container='window' style={{ zIndex: 2000 }}>
  {/* ... */}
</DialogView>

5. Sub components

<!-- Removed the "More Examples" section to align with FeedList structure -->

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.