slots-api
БесплатноБез исполняемых скриптовНе проверенMUI slots and slotProps API for deep component customization — replacing internal elements, custom renderers, and composition patterns
от TheLobbi★ 22 звезды на GitHubОб этом скилле
MUI Slots & slotProps API
The slots/slotProps pattern is MUI's primary mechanism for deep component customization. It lets you replace internal sub-components, inject custom renderers, and pass props to every layer of a compound component without wrapper hacks.
1. What Are Slots?
Every compound MUI component is built from smaller internal elements. The slots prop lets you swap any of those internal elements with your own component. The slotProps prop lets you pass additional props to each slot — whether you replaced it or not.
// Before (MUI v5 — deprecated)
<Autocomplete
PaperComponent={CustomPaper}
componentsProps={{ paper: { elevation: 8 } }}
/>
// After (MUI v6+ — slots API)
<Autocomplete
slots={{ paper: CustomPaper }}
slotProps={{ paper: { elevation: 8 } }}
/>
Key rules:
slotsaccepts component references (not JSX elements)slotPropsaccepts either a plain object or a callback function- Slot names are camelCase:
slots.valueLabel, notslots.ValueLabel - The component you provide receives all the props that the default slot component would receive — spread them through
2. Common Slot Patterns by Component
TextField
import { TextField, InputBase, FormHelperText } from '@mui/material';
// Replace the underlying input element
<TextField
label="Custom Input"
slots={{
input: InputBase,
inputLabel: CustomLabel,
}}
slotProps={{
input: {
sx: { borderRadius: 2, bgcolor: 'grey.50' },
'aria-describedby': 'helper-text',
},
inputLabel: {
shrink: true,
sx: { fontWeight: 600 },
},
formHelperText: {
sx: { fontSize: '0.75rem', color: 'warning.main' },
},
htmlInput: {
maxLength: 100,
pattern: '[A-Za-z]+',
},
}}
helperText="Letters only, max 100 chars"
/>
Autocomplete
import {
Autocomplete,
TextField,
Paper,
Popper,
type PaperProps,
type PopperProps,
type AutocompleteRenderOptionState,
} from '@mui/material';
import { forwardRef } from 'react';
// Custom paper with shadow and border radius
const StyledPaper = forwardRef<HTMLDivElement, PaperProps>((props, ref) => (
<Paper
{...props}
ref={ref}
elevation={8}
sx={{ borderRadius: 2, border: '1px solid', borderColor: 'divider' }}
/>
));
StyledPaper.displayName = 'StyledPaper';
// Custom popper with width matching
const WidePopper = forwardRef<HTMLDivElement, PopperProps>((props, ref) => (
<Popper {...props} ref={ref} placement="bottom-start" sx={{ minWidth: 400 }} />
));
WidePopper.displayName = 'WidePopper';
<Autocomplete
options={options}
slots={{
paper: StyledPaper,
popper: WidePopper,
listbox: CustomListbox,
}}
slotProps={{
paper: { 'data-testid': 'autocomplete-dropdown' },
popper: { modifiers: [{ name: 'offset', options: { offset: [0, 8] } }] },
listbox: { sx: { maxHeight: 300, '& .MuiAutocomplete-option': { py: 1 } } },
chip: { size: 'small', color: 'primary', variant: 'outlined' },
clearIndicator: { sx: { color: 'error.main' } },
}}
renderInput={(params) => <TextField {...params} label="Search" />}
/>
Select
import { Select, MenuItem } from '@mui/material';
<Select
value={value}
onChange={handleChange}
slots={{
root: CustomSelectRoot,
}}
slotProps={{
listbox: {
sx: {
maxHeight: 250,
'& .MuiMenuItem-root': {
borderRadius: 1,
mx: 0.5,
},
},
},
}}
>
<MenuItem value={10}>Ten</MenuItem>
<MenuItem value={20}>Twenty</MenuItem>
</Select>
Slider
import { Slider, type SliderThumbSlotProps } from '@mui/material';
import { forwardRef } from 'react';
// Custom thumb with tooltip-style display
const CustomThumb = forwardRef<HTMLSpanElement, SliderThumbSlotProps>(
(props, ref) => {
const { children, className, ...other } = props;
return (
<span ref={ref} className={className} {...other}>
{children}
<span style={{
position: 'absolute',
top: -28,
fontSize: 12,
fontWeight: 700,
background: '#1976d2',
color: '#fff',
borderRadius: 4,
padding: '2px 6px',
}}>
{props['aria-valuenow']}
</span>
</span>
);
}
);
CustomThumb.displayName = 'CustomThumb';
<Slider
value={sliderValue}
onChange={handleSliderChange}
slots={{
thumb: CustomThumb,
track: CustomTrack,
rail: CustomRail,
valueLabel: CustomValueLabel,
mark: CustomMark,
markLabel: CustomMarkLabel,
}}
slotProps={{
thumb: {
'data-testid': 'custom-thumb',
sx: { width: 24, height: 24 },
},
track: {
sx: { height: 8, borderRadius: 4 },
},
rail: {
sx: { height: 8, borderRadius: 4, opacity: 0.3 },
},
valueLabel: {
sx: { bgcolor: 'primary.dark', fontSize: 12 },
},
}}
marks={[
{ value: 0, label: '0' },
{ value: 50, label: '50
Установить slots-api в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadGlobGrepWriteEditFAQ
Что делает скилл slots-api?
MUI slots and slotProps API for deep component customization — replacing internal elements, custom renderers, and composition patterns
Как установить скилл slots-api?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл slots-api запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic