🎨
Valence
🎨
Valence
  • Overview
    • 👋Welcome to Valence
    • 🏄‍♂️Getting started
  • Core Concepts
    • Responsiveness
    • Color
      • List of colors
      • Color types
    • Polymorphism
  • Valence Core
    • 🏃‍♂️Fundamentals
      • 🎬The ValenceProvider
      • ✍️Using custom fonts
    • 🧱Components
      • 🔘Buttons
        • Button with icon
        • Grid Button
        • Text button
        • Icon button
        • Multi-part button
        • Unstyled button
        • Primitive button
      • ⌨️Inputs
        • Color Picker
        • Text input
        • Text area
        • Number input
        • Select input
        • Switch
        • Slider
        • Range slider
        • Pill selector
        • Input container
        • Dropdown container
      • 🖥️Display
        • Accordion
        • Alert
        • Color Swatch
        • Icon
        • Image
        • Avatar
        • Avatar Group
        • Loader
        • Pill
        • Spoiler
        • Stepper
        • Text
        • Title
      • 🧩Layout
        • App Container
        • Card
        • Flex
          • Flex Center
          • Styled Flex
        • Floating Toolbar
        • Grid
        • Header
        • Overflow Container
        • Space
      • 🗺️Navigation
        • App Nav
      • 🔼Overlays
        • Modal
        • Tooltip
        • Modal background
        • 📰Sheets
          • Bottom Sheet
          • Dynamic Sheet
          • Side Sheet
    • 🪝Hooks
      • UseColorScheme
      • UseColors
      • UseControlledList
      • UseDetectKeyDown
      • UseDisclosure
      • UseFloating
      • UseTooltip
      • UseBreakpoint
      • UseResponsiveProps
    • 🤚Generics
      • Generic button props
      • Generic input props
      • Generic Sheet Props
  • Valence Plugins
    • 🎠Valence Carousel
      • Carousel Child Props
  • Valence Utils
    • ✋Generics
      • Clickable
      • Events
      • Global
      • Grid
      • Layout
      • Overlay
      • Polymorphic
    • 🧜‍♀️Polymorphism
      • Polymorphic Button
      • Polymorphic Layout
      • Polymorphic Text
  • Update Notes
    • 3.0.0
    • 2.7.0
    • 2.6.0
    • 2.5.0
    • 2.4.0
    • 2.3.0
    • 2.2.0
    • 2.1.0
    • 2.0.0
Powered by GitBook
On this page
  • Usage
  • Controlled
  • Custom content
  • Props
  • TooltipProps
  • TooltipTriggerProps
  • TooltipContentProps
  • Changelog

Was this helpful?

Edit on GitHub
  1. Valence Core
  2. Components
  3. Overlays

Tooltip

Last updated: 2.0.0 (22/01/2024)

PreviousModalNextModal background

Last updated 1 year ago

Was this helpful?

Usage

import { Tooltip, Button } from "@valence-ui/core";

function MyComponent() { 
    return ( 
        <Tooltip>
            <Tooltip.Trigger>
                <Button>
                    I'm a button!
                </Button>
            </Tooltip.Trigger>
            <Tooltip.Content>
                I'm a tooltip!
            </Tooltip.Content>
        </Tooltip>
    )
}

Uncontrolled Tooltips will not show on .

Controlled

The Tooltip be used in a controlled fashion using the useDisclosure hook. The Tooltip will automatically hide when clicked away from (i.e. another element is focused), regardless of whether or not it is controlled.

import { Tooltip, Button, useDisclosure } from "@valence-ui/core";

function MyComponent() { 
    const disclosure = useDisclosure(false);

    return ( 
        <Tooltip
            disclosure={disclosure}
        >
            <Tooltip.Trigger>
                <Button
                    onClick={() => disclosure.open()}
                >
                    I'm a button!
                </Button>
            </Tooltip.Trigger>
            <Tooltip.Content>
                I'm a tooltip!
            </Tooltip.Content>
        </Tooltip>
    )
}

Custom content

The Tooltip.Content component accepts any valid JSX, or a raw string. This can be used to pass in icons or more complex content.

import { Tooltip, Button, Icon } from "@valence-ui/core";
import { Icon123 } from "@tabler/icons-react";

function MyComponent() { 
    return ( 
        <Tooltip>
            <Tooltip.Trigger>
                <Button>
                    I'm a button!
                </Button>
            </Tooltip.Trigger>
            <Tooltip.Content>
                <Icon>
                    <Icon123 />
                </Icon>
            </Tooltip.Content>
        </Tooltip>
    )
}

Props

TooltipProps

Property
Type
Description

children (required)

ReactNode

TooltipTriggerProps

Property
Type
Description

children (required)

ReactElement<any>

TooltipContentProps

Property
Type
Description

children (required)

string | ReactNode

withShadow

boolean

Whether to display a shadow underneath the tooltip.

zIndex

CSSProperties["zIndex"]

The z-index of the tooltip.


Changelog

Extends .

Extends .

2.2.0: Uncontrolled tooltips will no longer show on . Controlled tooltips (i.e. those that accept the disclosure prop) are unaffected.

🧱
🔼
mobile breakpoints
TooltipOptions
StyledFlexProps
mobile breakpoints