Hidden#
hidden bool 하나로 자식을 opacity + 축소 애니메이션과 함께 토글합니다. 접히는 축을 direction
(vertical/horizontal)으로 지정하고, 공간을 유지하려면 keepSpace: true, 역방향 접힘은
reverse: true.
Live Preview#
Web
Flutter
class HiddenDefaultExample extends StatefulComponent {
const HiddenDefaultExample({super.key});
@override
State<HiddenDefaultExample> createState() => _HiddenDefaultExampleState();
}
class _HiddenDefaultExampleState extends State<HiddenDefaultExample> {
bool _hidden = false;
@override
Component build(BuildContext context) {
final cs = context.theme.colorScheme;
final ts = context.theme.typography;
return div(
[
CoButton(
variant: CoreButtonVariant.primary,
onPressed: () => setState(() => _hidden = !_hidden),
child: Component.text(_hidden ? 'Show' : 'Hide'),
),
CoGap(size: CoreSpace.space12),
CoHidden(
hidden: _hidden,
child: div(
[
div(
[Component.text('Toggleable content')],
classes: 'text-${ts.bodyMedium} text-${cs.onSurface}',
),
],
classes:
'bg-${cs.surfaceContainer} rounded-${CoreRadius.scale.radius16} p-${CoreSpace.scale.space16}',
),
),
],
classes: 'flex flex-col items-start',
);
}
}
class HiddenDefaultExample extends StatefulWidget {
const HiddenDefaultExample({super.key});
@override
State<HiddenDefaultExample> createState() => _HiddenDefaultExampleState();
}
class _HiddenDefaultExampleState extends State<HiddenDefaultExample> {
bool _hidden = false;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CoButton(
variant: CoreButtonVariant.primary,
onPressed: () => setState(() => _hidden = !_hidden),
child: Text(_hidden ? 'Show' : 'Hide'),
),
CoGap(size: CoreSpace.space12),
CoHidden(
hidden: _hidden,
child: Container(
padding: EdgeInsets.all(CoreSpace.space16),
decoration: BoxDecoration(
color: theme.colorScheme.surfaceContainer!,
borderRadius: BorderRadius.circular(CoreRadius.radius16),
),
child: Text(
'Toggleable content',
style: theme.typography.bodyMedium.copyWith(
color: theme.colorScheme.onSurface,
),
),
),
),
],
);
}
}
사용 시기 (When to Use)#
이 컴포넌트를 사용하세요:
- 단일 영역을 부드럽게 보였다 숨겼다 해야 할 때 (알림·오류 메시지, 확장 드로어)
- 접힘 애니메이션이 필요하지만 헤더/트리거가 없는 경우
대신 다른 컴포넌트를 사용하세요:
Collapsible: 트리거(헤더)가 있는 접기/펼치기Swap: 두 콘텐츠를 교차 전환
기본 사용법 (Basic Usage)#
bool _hidden = false;
CoHidden(
hidden: _hidden,
direction: CoreHiddenDirection.vertical,
child: Text('Toggleable content'),
)
Props / Parameters#
CoHidden#
| 속성 | 타입 | 기본값 | 설명 |
|---|---|---|---|
child | W | 필수 | 토글되는 콘텐츠 |
hidden |
bool |
필수 | true면 opacity 0 + 축소, false면 원상태 |
direction |
CoreHiddenDirection? |
vertical |
vertical (height 접힘) / horizontal (width 접힘) |
duration | Duration? | 200ms | 전환 시간 |
keepSpace |
bool? |
false | true면 크기 유지, opacity만 애니메이션 |
reverse |
bool? |
false | true면 trailing edge(right/bottom)부터 접힘 |
curve |
Curve? |
easeInOut |
Flutter 전용 커브 (Web은 ease-in-out) |
semanticLabel | String? | null | 스크린리더 라벨 |
크로스 플랫폼 차이점 (Platform Differences)#
| 항목 | Flutter | Web |
|---|---|---|
| 클래스명 | CoHidden | CoHidden |
| child 타입 | Widget | Component |
| 렌더링 | AnimatedOpacity + _CoHiddenLayout (custom RenderBox) |
CSS transition: opacity, max-height, max-width |
| pointer 차단 | IgnorePointer(ignoring: hidden) |
pointer-events: none |
| reverse | layout offset 이동 | CSS transform-origin (bottom/right) |
| curve | Curves.* 노출 | 항상 ease-in-out |
관련 컴포넌트 (Related Components)#
- Collapsible: 트리거가 있는 접기/펼치기
- Swap: 두 콘텐츠 전환