### React Pagination Component Examples Source: https://context7.com/sima-land/ui-nucleons/llms.txt Illustrates the use of the Pagination component for navigating through pages of content. It includes basic usage, custom styling, and an example demonstrating URL synchronization with a router. Dependencies include React and @sima-land/ui-nucleons/pagination. ```tsx import { Pagination } from '@sima-land/ui-nucleons/pagination'; import { useState } from 'react'; function PaginationExample() { const [currentPage, setCurrentPage] = useState(1); const [items, setItems] = useState([]); const totalPages = 25; const itemsPerPage = 10; const handlePageChange = async (event, button) => { event.preventDefault(); const newPage = button.value; setCurrentPage(newPage); // Fetch data for the new page try { const response = await fetch(`/api/items?page=${newPage}&limit=${itemsPerPage}`); const data = await response.json(); setItems(data.items); // Scroll to top window.scrollTo({ top: 0, behavior: 'smooth' }); } catch (error) { console.error('Failed to fetch page:', error); } }; return (
{items.map((item) => (
{item.name}
))}
{/* Basic pagination */} {/* Custom styled pagination */}
); } // Example with URL sync function PaginationWithRouter() { const searchParams = new URLSearchParams(window.location.search); const initialPage = parseInt(searchParams.get('page') || '1', 10); const [currentPage, setCurrentPage] = useState(initialPage); const handlePageChange = (event, button) => { event.preventDefault(); const newPage = button.value; setCurrentPage(newPage); // Update URL const url = new URL(window.location.href); url.searchParams.set('page', newPage.toString()); window.history.pushState({}, '', url); }; return ( ); } ``` -------------------------------- ### Install UI-Nucleons via npm or yarn Source: https://context7.com/sima-land/ui-nucleons/llms.txt Instructions for installing the UI-Nucleons package using either npm or yarn package managers. This is the first step to integrate the component library into your project. ```bash npm install @sima-land/ui-nucleons # or yarn add @sima-land/ui-nucleons ``` -------------------------------- ### React Select Component Example Source: https://context7.com/sima-land/ui-nucleons/llms.txt Demonstrates the usage of the Select component for creating dropdown menus. It supports controlled and uncontrolled modes, custom opener and menu rendering, and integrates with other UI elements. Dependencies include React and @sima-land/ui-nucleons/select. ```tsx import { Select } from '@sima-land/ui-nucleons/select'; import { SelectFieldBlock, SelectMenu, SelectOption } from '@sima-land/ui-nucleons/select'; import { useState } from 'react'; interface Option { value: string; label: string; } function SelectExample() { const [value, setValue] = useState(''); const countries: Option[] = [ { value: 'us', label: 'United States' }, { value: 'uk', label: 'United Kingdom' }, { value: 'ca', label: 'Canada' }, { value: 'au', label: 'Australia' }, { value: 'de', label: 'Germany' }, ]; return (
{/* Controlled select */} { console.log('Changed to:', newValue); }} /> {/* Custom styled select */}