Socket
Socket
Sign inDemoInstall

@sanity/types

Package Overview
Dependencies
4
Maintainers
39
Versions
832
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @sanity/types

Type definitions for common Sanity data structures


Version published
Weekly downloads
195K
decreased by-15.18%
Maintainers
39
Install size
8.69 MB
Created
Weekly downloads
 

Readme

Source

Usage

Regular list

import type React from 'react'
import {List, Item} from 'part:@sanity/components/lists/default'

function renderItem(item, index) {
  return <Item className="myListItem">{item}</Item>
}

function MyComponent() {
  return <List className="myList" items={['a', 'b', 'c']} renderItem={renderItem} />
}

Sortable list

import {List, Item, DragHandle} from 'part:@sanity/components/lists/sortable'
;<List className="myList">
  <ListItem>
    <DragHandle />
    Hello this is sortable list item
  </ListItem>
</List>

Grid list

import {List, Item} from 'part:@sanity/components/lists/grid'
;<List className="myGridList">
  <ListItem>Hello this is grid list item #1</ListItem>
  <ListItem>Hello this is grid list item #2</ListItem>
  <ListItem>Hello this is grid list item #3</ListItem>
</List>

Sortable grid list

import {List, Item} from 'part:@sanity/components/lists/sortable-grid'
;<List className="myGridList">
  <ListItem>
    <DragHandle />
    Hello this is sortable grid list item #1
  </ListItem>
  <ListItem>
    <DragHandle />
    Hello this is sortable grid list item #2
  </ListItem>
  <ListItem>
    <DragHandle />
    Hello this is sortable grid list item #3
  </ListItem>
</List>

Custom drag handle

To create a custom drag handle, you can import the custom createDragHandle function. This works for both regular sortable lists and sortable grid lists.

import {List, ListItem, createDragHandle} from 'part:@sanity/components/lists/sortable'

const MyDragHandle = createDragHandle(<span>Drag me!</span>

<List className="myGridList">
  <ListItem>
    <MyDragHandle />
    Hello this is sortable list item #1
  </ListItem>
  <ListItem>
    <MyDragHandle />
    Hello this is sortable list item #2
  </ListItem>
  <ListItem>
    <MyDragHandle />
    Hello this is sortable list item #3
  </ListItem>
</List>

Keywords

FAQs

Last updated on 25 Jul 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc